|
HOME
|
Cursur to start of line
|
|
END
|
Cursur to end of line
|
|
TAB
|
Autocompletion
|
|
!!
|
Repeat last Bash cmd
|
|
cd foldername
|
change director to foldername
|
|
cd ..
|
go up one folder
|
|
ls
|
list services- shows files in current directory
|
|
man <cmd>
|
shows manual for <cmd>
|
|
clear
|
clears terminal
|
|
reset
|
resets terminal but doesn't restart service
|
|
CTRL-Z
|
Stops current running function
|
|
CTRL-J
|
Same as RETURN
|
|
DEL
|
deletes backward from pointer
|
|
exit
|
logs out of current session
|
|
cat 'filename'
|
prints file to std out on terminal
|
|
pwd
|
print working directory
|
|
wc 'filename'
|
word count of filename
|
|
echo 'string or filename'
|
prints string or filename on the terminal
|
|
cat > 'filename'
|
takes standard input into file
|
|
head 'filename'
|
prints first 10 lines of file
|
|
tail 'filename'
|
prints last 10 lines of file
|
|
cut -b
|
specific bytes
|
|
cut -b 1,2,3
|
bytes 1 2 and 3
|
|
cut -b 1-3,5-7
|
bytes 1-3 and 5-7
|
|
cut -b 1-
|
from first byte to end of line
|
|
cut -d
|
use a delimiter
|
|
cut -d " "
|
outputs from beginning of line to first space
|
|
gcc 'filename.c'
|
C files
|
|
chmod +x 'filename.sh'
|
Bash script files
|
|
g++ 'filename.cpp'
|
CPP files
|
|
javac 'javafile'
|
JAVA
|
|
python 'filename'
|
to run python scripts
|
|
gcc -o newname 'filename.c'
|
change name of compiled program
|
|
g++ -o newname 'filename.cpp'
|
change name of compiled program
|
|
grep 'string' </dir/filename.log>
|
outputs all lines that match 'string'
|
|
grep 'string' filename1 filename2
|
output all lines that match 'string' in multiple files
|
|
grep -i 'string' filenmae
|
ignores case
|
|
grep [-options] 'string'
|
grep standard output
|
|
grep [-options] 'string' filename
|
grep the contents of a file
|
|
grep -A n 'string' filename
|
displays n lines after string
|
|
grep -B n 'string' filename
|
displays n lines before string
|
|
grep -v 'string' filename
|
returns all lines which don't match 'string'
|
|
grep -E
|
allows extended regular expressions
|
|
grep -E 'string{n}'
|
get lines with n number of string in it
|
|
grep -c
|
count results
|
|
grep -n
|
show line number
|
|
grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 'filename'
|
Ip address
|
|
grep -srhw "[[:alnum:]]\+@[[:alnum:]]\+" 'filename'
|
email address
|
|
grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 'filename'
|
Ip address
|
|
grep -srhw "[[:alnum:]]\+@[[:alnum:]]\+" 'filename'
|
email address
|
|
cmdX||cmdY
|
run cmdX if it fails then run cmdY
|
|
cmdX && cmdY
|
run cmdX if it doesn't fail run cmdY
|
|
cmd &
|
will push cmd to background
|
|
cmd & >/dev/null &
|
will put cmd to background and not display cmd outputs
|
|
disown
|
typed after pushing cmd to background to disown cmd from current terminal
|
|
jobs
|
show disowned jobs
|
|
sed G
|
double space a file
|
|
sed 'G;G'
|
triple space a file
|
|
sed -n '$='
|
count lines
|
|
sed = filename | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'
|
number each line of a file
|
|
sed 's/^[ \t]//;s/[ \t]$//'
|
delete both leading and trailing whitespace
|
|
sed 's/[ \t]*$//'
|
delete trailing whitespace
|
|
sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
|
reverse all characters on the line
|
|
sed 10q
|
print first 10 lines of file
|
|
sed q
|
print first line of file
|
|
sed -e :a -e '$q;N;11,$D;ba'
|
Last 10 lines of file
|
|
sed -n '/regexp/p'
|
print only line that matches regex
|
|
sed -n '8,12p'
|
print lines 8-12
|
|
sed '1,10d'
|
delete first 10 lines of a file
|
|
.
|
Matches any single character
|
|
\d
|
number in 0-9
|
|
\D
|
non number
|
|
\w
|
"word" letters, digits and _
|
|
\W
|
non word
|
|
\r
|
return
|
|
\n
|
newline
|
|
\s
|
whitespace
|
|
\S
|
non whitespace
|
|
'term'*
|
0 or more repetitions of term
|
|
'term'+
|
1 or more repetitions of term
|
|
'term'?
|
0 or one instances of term
|
|
'term'{n}
|
exactly n instances of term
|
|
'term'{n,}
|
atleast n instances of term
|
|
'term'{x,n}
|
between x and n instances of term
|
|
(term1|term2)
|
term1 or term2
|
|
[0-9]
|
matches any number
|
|
[a-z]
|
matches any letter
|
|
[aeiou]
|
matches vowels
|
|
([A-Za-z0-9-]+)
|
letters numbers and hyphens
|
|
(\d{1,2}\/\d{1,2}\/\d{4})
|
European Date (eg. 21/3/2018 )
|
|
(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})
|
email addresses
|
|
> 'file'
|
create file or overwrite if existing
|
|
>> 'file'
|
append to the file
|
|
< 'file'
|
read from file
|
|
X|Y
|
pipe X as input to Y
|
|
./a.out
|
for recently compiled program
|
|
./'script.sh'
|
bash script
|
|
./'compiledname'
|
name changed compiled program
|
|
'name of installed program'
|
eg. gedit, nano, vim
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.