There’s more to using the Linux terminal than just typing commands into it. Learn these basic tricks and you’ll be well on your way to mastering the Bash shell, used by default on most Linux distributions.
This one’s for the less experienced users – I’m sure that many of you advanced users out there already know all these tricks. Still, take a look – maybe there’s something you missed along the way.
Tab Completion
Tab completion is an essential trick. It’s a great time saver and it’s also useful if you’re not sure of a file or command’s exact name.
For example, let’s say you have a file named “really long file name” in the current directory and you want to delete it. You could type the entire file name, but you’d have to escape the space characters properly (in other words, add the \ character before each space) and might make a mistake. If you type rm r and press Tab, Bash will automatically fill the file’s name in for you.
Of course, if you have multiple files in the current directory that begin with the letter r, Bash won’t know which one you want. Let’s say you have another file named “really very long file name” in the current directory. When you hit Tab, Bash will fill in the “really\ “ part, since the files both begin with that. After it does, press Tab again and you’ll see a list of matching file names.
No comments:
Post a Comment