Linux Environment Variables and Shell Scripting Flashcards
how to display a list of all the env variables
printenv or env
what does echo $HOME do
The absolute path of the home directory
what does echo $PATH
The value of the command search path.
what does echo $PS1 RETURN
The value of the primary prompt.
what does echo $PS2 RETURN
The value of the secondary prompt
what does echo $PWD RETURN
The absolute path of the current work directory.
WHAT DOES echo $SHELL RETURN
The absolute path of the login shell.
WHAT DOES echo $USER RETURN
name of current user logged in
Two processes connected by a pipe run in ________
parallel
what does ls | wc mean
ls is the producer
wc is the consumer of this output
how to look for all txt files
ls | grep txt
how to count number of lines in linux
wc -l
how to count number of characters in linux
wc -m
how to count number of bytes in linux
wc -c
how to view contents of a file
cat filename
how to read input from key board and save to file
cat > filename
ctrl + d to stop
how to sort data in file
sort < filename
how to append output to a file
echo world»_space; filename
sort the file and save the output to another file
sort < data.txt > sortedData.txt
what does output 116 mean when wc cmd is used
1 line
1 word
6 bytes
what does cat hello.txt 1>data.bak 2>error.txt
if cat hello.txt has no error the output will be saved to data.bak
else it will be saved to error.txt
how to quote meta characters
-using backslash (): echo \; hello
-using single quote (‘) echo ‘;hello’
-using double quote (“) echo “;hello”
how to return “today’s date is 29 feb 2022”
echo “today’s date is $DATE”
or
echo “today’s date is DATE
”
make a name variable equal to student
NAME=student
echo $NAME (for checking)