CtrlK

Fundamentals

Filtering content

Viewing files:

less file_name
cat file_name | more

First few lines or last few lines of a file

first n lines:
head -n number 10 by default

last n lines:
tail -n number 10 by default

Unique entries

First use sort and then pipe it to uniq
cat file | sort | uniq

Compare 2 files: diff

Split line with delimiter: cut -d ":" -f [postion of the column]

one character delimiter only

Replace a specific character in a line: tr "to change" "change with"

Rotating or shifting characters

cat file.txt | tr "a-zA-z" "c-za-bC-ZA-B"

Clear representation of multiple fields: column -t

print specific field values: awk

awk {'print $1, $NF'}
$NF: last column

Replace specific strings in a line: sed

**Sed: **sed 's/pattern1/pattern2/g'
change specific names in the whole file or standard input
"s" flag at the beginning: substitute command. Then the pattern we want to replace.
After slash (/), enter replacement pattern in the third position. Finally "g" flag stands for replacing all matches. **Eg: **sed 's/bin/HTB/g'

Hex Encoding

Encode: xxd -p "text to encode"
Decode: xxd -r -p "text to decode"