Redirection

$ cat hello.txt
outputs content to terminal

$ echo "hello"
prints "hello"

> — this redirects the output on the left and inputs it to the right (overright)

< — same but from right to left

-- redirect --

$ echo "Hello" > hello.txt
contents of hello.txt = "Hello"

$ cat " hello" >> hello.txt
contents of hello.txt += " hello"

-- piping output --
Just think of it as a way of chaining commands together


cat output.txt | inputThing
the output of output.txt is directed to inputThing and then run

cat output.txt | inputThing | cat > file.txt
same thing but output is stored in file.txt

-- sort --

$ sort file.txt
sorts the contents of the file into alphabetical order

$ cat file.txt | sort < sortedFile.txt
inputs file, sorts it, then puts it in a new file

-- unique --

$ uniq file.txt
removes duplicate lines that are next to each other

$ sort file.txt | uniq uniqFile.txt
sorts the file, removes duplicate lines, stores in new file 

-- infile search --

$ grep wordYouAreLookingFor file.txt
lists out all lines with the phrase

$ grep -i wordYouAreLookingFor file.txt
makes it case insensitive

$ grep -R word file.txt
searches the dir

$ grep -l word file.txt
returns the file name if containing the phrase

-- find and replace --

$ sed 's/FIND/REPLACE/g' file.txt
swap FIND and REPLACE with the respective words, and output to terminal

$ sed -i 's/FIND/REPLACE/g' file.txt
same but rewites the actual file