Bash Scripting Flashcards
what is relative path?
location from the current directory
what’s absolute path?
something like /bin/ping
-used in case the program is not specified in PATH
~
current user’s home directory
*
wildcard used for finding certain types of files
output
results of command in a bash shell
command > file.txt
create or overwrite
command»_space; file.txt
create or append
what are 2 types of output redirection
- to a file
2. to another command
what bash character sends output to another command?
(pipe)
what is a “oneliner” script?
chaining multiple commands to automate a task
what does this oneliner do?
file ‘ls /etc/*conf’ | sort > test.txt && cat test.txt | wc -l
- anything between ‘’ operator gets evaluated first
- for each file listed (ls), it is sorted and put into a text file called test.txt
- && means execute what’s after it if the previous commands were successful
- read the test.txt file and print out the number of lines (wc = word count -l = lines)
what extension does a bash script file have?
.sh
what is the first line of any bash script file?
!/bin/bash
after saving a bash file, what should you make sure of?
make sure the file is executable, change the permissions
how do you make a file executable?
chmod+x