Codecademy Terminal Commands Flashcards
>
$ cat oceans.txt > continents.txt
takes the standard output of the command on the left, and redirects it to the file on the right.
>
$ cat oceans.txt > continents.txt
takes the standard output of the command on the left, and redirects it to the file on the right.
> >
$ cat glaciers.txt»_space; rivers.txt
> > takes the standard output of the command on the left and appends (adds) it to the file on the right.
|
$ cat volcanoes.txt | wc
is a “pipe”. The | takes the standard output of the command on the left, and pipes it as standard input to the command on the right. You can think of this as “command to command” redirection.
~/.bash_profile
$ nano ~/.bash_profile
~/.bash_profile is the name of file used to store environment settings. It is commonly called the “bash profile”. When a session starts, it will load the contents of the bash profile before executing commands.
alias
alias pd=”pwd”
The alias command allows you to create keyboard shortcuts, or aliases, for commonly used commands.
$ cat < lakes.txt
< takes the standard input from the file on the right and inputs it into the program on the left.
|
$ cat volcanoes.txt | wc
is a “pipe”. The | takes the standard output of the command on the left, and pipes it as standard input to the command on the right. You can think of this as “command to command” redirection.
~/.BASH_PROFILE
$ nano ~/.bash_profile
~/.bash_profile is the name of file used to store environment settings. It is commonly called the “bash profile”. When a session starts, it will load the contents of the bash profile before executing commands.
ALIAS
alias pd=”pwd”
The alias command allows you to create keyboard shortcuts, or aliases, for commonly used commands.
env | grep VARIABLE
env | grep PATH
env | grep PATH is a command that displays the value of a single environment variable.
cp
$ cp ada_lovelace.txt historical/
cp copies files or directories. Here, we copy the file ada_lovelace.txt and place it in the historical/ directory
*
$ cp * satire/
The wildcard * selects all of the files in the current directory. The above example will copy all of the files in the current directory to the directory called satire. There are other types of wildcards, too, which are beyond the scope of this glossary.
$ cp m*.txt scifi/
Here, m*.txt selects all files in the working directory starting with “m” and ending with “.txt”, and copies them to scifi/.
env
The env command stands for “environment”, and returns a list of the environment variables for the current user.
ENV | GREP VARIABLE
env | grep PATH
env | grep PATH is a command that displays the value of a single environment variable.
export
export USER=”Jane Doe”
export makes the variable to be available to all child sessions initiated from the session you are in. This is a way to make the variable persist across programs.
grep
$ grep “Mount” mountains.txt
grep stands for “global regular expression print”. It searches files for lines that match a pattern and returns the results. It is case sensitive.
grep -i
$ grep -i “Mount” mountains.txt
grep -i enables the command to be case insensitive.
grep -R
$ grep -R Arctic /home/ccuser/workspace/geography
grep -R searches all files in a directory and outputs filenames and lines containing matched results. -R stands for “recursive”.
grep -Rl
grep -Rl Arctic /home/ccuser/workspace/geography
grep -Rl searches all files in a directory and outputs only filenames with matched results. -R stands for “recursive” and l stands for “files with matches”.
HOME
$ echo $HOME
The HOME variable is an environment variable that displays the path of the home directory.
ls
$ ls
2014 2015 hardware.txt
ls lists all files and directories in the working directory
ls -a
ls -a
. .. .preferences action drama comedy genres.xt
ls -a lists all contents in the working directory, including hidden files and directories
ls -l
ls -l
drwxr-xr-x 5 cc eng 4096 Jun 24 16:51 action
drwxr-xr-x 4 cc eng 4096 Jun 24 16:51 comedy
drwxr-xr-x 6 cc eng 4096 Jun 24 16:51 drama
-rw-r–r– 1 cc eng 0 Jun 24 16:51 genres.txt
ls -l lists all contents of a directory in long format.