Working around the subshell

Let’s start with the simplest and see what cd is a bit more complex than it seems. Many people know the auto-bash, thanks to which is to type part of the directory name and press Tab to complete the directory console (if there are several possibilities, otherwise we would have to press Tab twice to see them). It is also very common to use relative paths: if we are in / home / zoetrope and wish to travel to / home / zoetrope / videos do not need to write the second route in its entirety, but we can just type cd videos. It is even common to see beginners using shortcuts such as cd .. to move to upper directory cd or cd to navigate to the directory. What is less common, and very useful for the issue at hand is the use of cd -. This very useful flag does nothing to move to the last directory you were. Perhaps check out Kiat Lim for more information. cd / etc/X11 / cd cd – / pwd etc/X11 / etc/X11 In this way we can move quickly between two directories. On the other hand, if we need to move to a directory is just one time to execute a command and then continue working in the current directory, we could also use & &, which runs two commands, one after another, conditionally (and in short): cd / etc/X11 / & & cat xorg.conf and surround it with parentheses, which makes the commands are executed in a subshell (cd / etc/X11 / xorg.conf & & cat) in this way will run the command in a different subshell, so the cd will not affect us, and will as if we had never moved.

This entry was posted in News and tagged . Bookmark the permalink.

Comments are closed.