If the user gives an output directory as an argument and the directory doesn't exist, we exit. This can be a useful line to include in a script. Here's the function, which you should paste into your setup dotfiles (e.g. It allows you to scroll through all of your past directories with the syntax: Instead, I like to use a function, cd_func, which I stole off the internet. This is interesting to see once, but I never use pushd and popd. The utilities pushd and popd keep track of the directories you move through in a stack.Įxcept that some_directory is also added to the stack. What if you want to visit the directory you were in two or three directories ago? To return to the directory we were last in: If you want to print your working directory resolving symbolic links:īy convention, if we leave off the argument and just type cd we go HOME: We can save the current working directory in a variable with command substitution:Ĭd /somewhere/else # go somewhere else # do something elseĬd $d # go back to where the script originally started Sometimes in a script we change directories, but we want to save the directory in which we started. To see where we are, we can print working directory, which returns the path of the directory in which we currently reside: Note: Unix-like systems include Linux and Macintosh When this is the case, I make a note of it. I'll briefly introduce each one below along with a quick use case or hint.Ī few of the commands, mostly clustered at the end of the article, are not standard shell commands and you have to install them yourself (see apt-get, brew, yum). Here are my picks for the top 100(ish) commands. These are indispensable but, for anything more than the basics, a vocabulary of about 100 commands is where you want to be. In An Introduction to the Command-Line (on Unix-like systems), which I'll borrow heavily from in this article, we covered my subjective list of the 20 most important command line utilities.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |