pwd |
tell you where you are |
ls |
list the content of the current directory |
ls <directory> |
list the content of a directory |
cd <directory> |
go to the specified directory |
cd ~ (or cd) |
go to your home directory |
cd .. |
go to the parent directory |
tree <directory> |
list the content of a directory in a tree-like format |
mkdir <directory> |
create the specified directory |
less, more |
view text with paging |
head |
print first lines of a file |
tail |
print last lines of a file |
cat |
print the content of a file to the screen |
zcat |
print the content of a |
rm <file> |
remove |
cp <file1> <file2> |
copy |
mv <file1> <file2> |
rename |
find <folder>/ -type f |
recursively find all files in a specific folder |
find . -name '<pattern>' |
recursively find anything whose name contains <pattern> in the current folder (Single quotes must be used in order to avoid wildcard expansion by the shell) |
grep <pattern> |
show lines of text containing a given pattern |
grep -v <pattern> |
show lines of text not containing a given pattern |
sort |
sort lines of text files |
wc |
count words, lines and characters |
> (output redirection) |
allow to redirect the output to a file |
| (pipe) |
allow to send the output from one program to another |
cut |
extract selected portion of each line from one or more files |
echo |
input a line of text and display it on standard output |
AWK - UNIX shell programming language. A fast and stable tool for processing text files.
awk '/www/ { print $0 }' <file> |
search for the pattern |
awk '$3=="www"' <file> |
search for the exact match of |
awk 'length($0) > 80' <file> |
print every line in the file that is longer than 80 characters |
awk 'NR % 2 == 0' <file> |
print even-numbered lines of the file |
NR |
Number of records |
NF |
Number of fields |
FS |
Field separator character |
OFS |
Output field separator character |
Note
|
See http://www.grymoire.com/Unix/Awk.html and http://www.tutorialspoint.com/awk/awk_basic_examples.htm for more information |