4 - Linux Basic & Admin
4 - Linux Basic & Admin
[email protected]
File Compression & Extraction
File Compression methods 100MB
GunZip ----> ¼ size 25MB
BunZip ----> ⅛ size 12 MB
File data : char, numbers, alphanumeric, binary, raw, duplicate
For Compression
#tar -cf <name>.tar <name>.txt (tar)
#tar -czf <name>.tar.gz <name> (gunzip)
#tar -cjf <name>.tar.bz2 <name>
For Extraction
#tar -xf <name>.tar
#tar -xzf <name>.tar.gz
#tar -xjf <name>.tar.bz2
DevOps ----- [email protected]
HEAD
Syntax:
#head [option] <file name>
Ex:
#head <file name> ---> list first 10 lines
#head -n 5 <file name> ---> list first 5 lines
TAIL
Syntax:
#tail [option] <filename>
Ex:
#tail <file name> ----> list last 10 lines #tail -n 3 <file
name> ----> list last 3 lines #head -n 4 <file name> |
tail -n 1 ----> list 4th line #head -n 4 <file name> |
tail -n 2 ---> list 4 & 5 line
DevOps ----- [email protected]
GREP
Syntax:
#grep [option] <string> <file name> Ex:
#grep -e Hello demo.txt
#grep -e Hello -e Devops demo.txt #grep -i
Hello demo.txt -----> ignore cases #grep -l Hello
*.txt -----> list all files #grep -v Hello demo.txt
----> other lines
PASTE
Syntax:
#paste <file1> <file2>
Ex:
#paste file1 file2
#paste file1 file2 > file3
#paste -d ‘$’ file1 file2
#echo ‘<content>’ &>><file name> ----- to append content at
last
#cat <file name 1> >> <file name 2> ----> copyes data from file1 and appends data
into file2