Bash

grep find sed awk

# look through current directory's hieracrhy for text in file
grep -rnw '/path/to/somewhere/' -e 'pattern'

# recursively delete all files of a single extension
find . -name "*.bak" -type f -delete    

# recursive print all file with extension .py
find $directory -type f -name "*.in"    

find ./ -name '*article*' | xargs -I '{}' mv {} ../backup
find ./ -name '*article*' | xargs mv -t ../backup

i/o & operators

wc # wordcount
cat 
less
sort -n
head -n {how many} {file}
tail -n {num} {file}
file name {*[ab].*}   ——> prints files with a or b in that position
uniq {file}   —> removes adjacent duplicated lines
cut   —>  removes portions of lines from a file
w   —> prints current user and what they are doing

# wc all text files in current  directory
wc *.txt

A; B    # Run A and then B, regardless of success of A
A && B  # Run B if and only if A succeeded
A || B  # Run B if and only if A failed
A &     # Run A in background.

*  # wildcard for array of chars
?  # wildcard for single char
>  # redirect shell output to file appends
>> # redirect shell output to file overwrites
!  # boolean NOT 
&& # boolean AND 
|| # boolean OR
** # exponentiation
%  # modulo
;  # separate lines in terminal prompt

networking

# show list of all http port connections active, use sudo with lsof to include system connections
netstat -ap tcp || grep -i “listen”
lsof -PiTCP -sTCP:LISTEN

# make an http request and trace out what happens on the way

curl 
    -verbose 
    -trace-ascii debugdumplog.txt   
    -o redirect output
    URL = 

regex

[a-z]_
[0-9]_
^
.\*
which {package} # show address of version in use
exec bash   # restart shell
printenv    # show all env variables
!histnum    #run command from history
chsh -s     # change shell zsh bash etc

type -a [command]

df  # show disk files on machine
whoami  # display user name
chmod   
mkdir {name}    # makes a directory with a name
mv  # move files to new directory
pwd     # what is present working directory
stat --help # lots of good stuff
ps -Eafx::  # shows information about the current processes running in shell

loops

# starts by expanding *.filetype
for {x} in {*.filetype};  do blah;  done ;

# prints to output
echo {text for anything to output}

!!   ———> last run command

!$  ————> run last word of previous command

scripts

bash {script.sh} {$inputvar1}

.bashrc

alias
bind


# PS1 is the environment variable that contains the shell prompt. 
https://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html

# '\e[0;31m' is the terminal escape sequence to change color to red. # '\u' is the user name
# '\e[m' means "return to the default text color"
PS1="\e[0;32m\h \W\:~ \e[m "  ### red hostname cwd:~