Bash cheat sheet
pwd
tree <path>
cd <path>
ls <path>
ls -a <path>
-a
to show hidden files
mkdir <flags> <path(s)>
mv <flags> <sourcePath(s)> <destinationPath>
cp <flags> <sourcePath(s)> <destinationPath>
rm <flags> <filePath(s)>
alias <aliasName>='<commandToRun>'
alias rm='rm -i' # confirm to delete file
alias rm='mv -t -/.tash' # move file to a trash directory
alias cp='cp -b' # make backup of destinationFile
alias mv='mv -u' # move only if sourceFile is newer
alias hello="echo 'cow power'"
cat <flags> <file>
less <flags> <file>
less
outputs a page at a time, to scroll through
- Can search through file using the /<word>
head <flags> <file>
-n <number of lines>
to print certain number of lines from file
tail <flags> <file>
nano <flags> <file>
vim <flags> <file>
man <command>
man mkdir
man stdio
tldr <flags> <command>
grep 'word-to-search' <file_name>
grep 'word-to-search' <file_name1> <file_name2> <file_name3> ...
grep 'pattern' <file_name> # searches by regex pattern
grep 'Gandalf' list_of_dwarves.txt
if [[ $? != 0 ]]
then
echo "Gandalf is not a dwarf"
exit 1
else
echo "Gandalf is a dwarf"
exit 0
fi
$?
stores the exit code for the last command
p10k configure
powerlevel10k
looks
-
https://www.cyberciti.biz/faq/grep-in-bash/ ↩