grip 'n'lines present after
the pattern
grep -An < patterns-files
grep 'n' lines present before
the pattern
grep -Bn-patterns files
grip 'n' lines before and
after the pattern
grip-on-patterns-files
use grip to find a keyword
match in multiple files
grip query file I file 2 files
search in all files in a
directory
grep query *
search for multiple keywords
• grep 'query I-I query 2' file
• egrep 'query 1 I query 2'
file
• grip -e query 1 -equery 2
file
• grip-E 'query 11 query 2'
file
to match the start of the line
grip '^ query' file
to match the end of the line
grep 'query $' file
to match start andend of line
grep "^ query.* query$'
display line number
grip-n -patterns-files gives
line number where pattern
is present
print non-matching lines
grep-v < patterns -files
to search between all the lines in
sub-directories and files inside
the current directory
grip-r 2 patterns <paths
copy content of one file to
another file
cat bile I.tt file 2. but >
merged-file. bit combines the
content of file 1 and file 2
into a new file named merged
file
view file with line number
cat-n filename
view file without repeated empty
lines
cat-5 filename
add contents of one file to
another
cat file I → file 2 appends
contents of files to the end of
file 2
display contents of a file in
reverse order
tac filename
highlight end of each line in a
file
cat-E filename
combine-v.-EI-Tm one
command
cat -A filename
displays content of file with non
printing characters visible, line
endings highlighted and tabs
displayed as "l'
display content of all tent files in
a folder
cat * tret
du command in Unin
du is disk usage used to
estimate file space usage
size of all files in a directory
du directory,
print file size in k, M, B format
du-h -directory,
display all files within a
directory and subdirectories with
their sizes
du-a -h -directory?
display total size of a directory
and its subdirectories
du-c-h (directory?
disk usage summary for a
directory
du-s -directory,
view timestamp of last
modified files and directories
du --time -h-directory,
find largest directory on the
system
du --max-depth = I /path
find large files within a
directory using du
find /path -type f -exec
du-h {3 + I sort-rh/
head -n 10
exclude certain directories or
files
du-h --exclude = path to
exclude > < paths
to print size to particular level
du -d no <path 7
n → level no.
du options
print lines that match the given
pattern
awk '/pattern/ {print}' file
split a line into fields
awk ' {print $1, $43' file
command will print 1st and 4th
column
display line number using
awk
awk '{print NR, $03' file
display 1st and last column
awk " {print $1, $NF}' file
display line from 3106
awk "NR= =3, N R = = 6 {print
NR, $03' file
print row number and 1st
column,separated by '-'
awk ' {print NR "-"$1}' file
to print non empty line if
present
awk 'NF-=-◦ {print NR}' file
find length of longest line
present in a file
curk ' {if (length ($077 max)
max = length ($07} END
{print max}' file
count lines in a file
awk 'END {print NR} 'file
print lines with more than 10
characters
awk 'length ($07710" file
find I check for any string in
any specified column
awk '{if ($3 = = "BG") print
$0:}' file
open last edited file
ls-t
sorts file by modification
time, showing last edited
file first
display one file per line
Is-I
display file size in Mik,B format
ls-th