For testing purposes, I usually create a series of files to run my bash scripts against and I love using the
Awesome! This allows me to:
jot 8 | xargs touch
I also use it to generate random series of numbers:
jot -r 10
What if you want to specify a range of numbers to which the randomisation occur?
jot -r 10 580 900
The above gives you 10 random numbers between 580 to 900. Awesome, right? Then there’s more - you can prepend a word to it!
jot -w file_%d -r 10 580 900
Like I said, I love the
jot command. There’s a lot more use of this nifty little command. I only cover those I use often.
For the rest of it, you can go through the tutorial here.
Ever come across a situation where you need to do this (very quickly):
rm -rf *
And you get this (with the
rm: remove regular file 'PRON_0001.jpg'?
Sh*t! I have to hit
'y' to every single file? Well, you can use the
The yes command generates an infinite loop of
'y'. So, your problem solved:
yes | rm -rf *
Of course the above example uses the
rm command, which can be solved with the
-f flag but you can use it for any other commands that doesn’t offer such an option.
I always love doing things without my fingers leaving the keyboard. So, the more I can do from my terminal, the better. Over the years, I’ve come to like quite a few really handy commands.
Open most files as if you double clicked on it in
Finder where you are in terminal?
Emailing output to yourself (you need to enable
ps aux | mail -s "Subject line" email@example.com
You should be able to check if the email has been placed in queue:
You should see something like this if you’re quick (before it gets sent):
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
6762CA18F19* 20039 Sat Jun 9 20:12:03 firstname.lastname@example.org
-- 19 Kbytes in 1 Request.
Oh this works on any Linux with
mailx and local mta installed.
How about copying something in terminal to clipboard?
cat some_text.txt | pbcopy
You can then use
Ctrl+V anywhere. And if you want to past from clipboard:
pbpaste > from_clipboard.txt
Other misc tools
Current Mac version:
Screencapture (full tutorial here):
That’s it! Now go have fun!