5 useful Mac OS X command line tips you should know
Like many other power users, I’m addicted to the Mac OS X command line, any reason at all for me to launch the terminal I take as an opportunity to learn more about the powerful backend of our favorite operating system. Here I have gathered 5 useful commands that will make your life easier when you’re working in the command line interface, so launch the Terminal and try them out! If you have any others that you think should be added to this list, feel free to post them in the comments, and be sure to check out 10 OS X Command line utilities you might not know about for more.
Delete an entire line of commands/text
Don’t repeatedly hit the delete key, all you need to do to clear your prompt is hit
Control-U and your slate will be clean.
Create a nested directory structure immediately
If you need to create the directory structure /annoyingly/long/and/outrageous/directory/path/ , instead of typing mkdir annoyingly, cd annoyingly, mk long , etc etc, simply type the following:
mkdir -p /annoyingly/long/and/outrageous/directory/path/ and your nested directory structure will be created in full immediately!
Clear the Terminal screen
If you have a screen full of nonsense, clearing the Terminal screen is very easy, you can either type
clear or just hit
Control-L and you’ll have a clean slate.
Run a process in the background
If you want to set a process to run in the background, simply put a & after it, the command will execute but you’ll still be in the same shell, allowing you to continue as usual.
Run the last executed command
!! will run whatever the last command that was executed, typing
!l will run the last command starting with the letter l, and so forth.