Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Archiving and Compression

Pipe and Redirection


Redirection
• Default input  keyboard
• Default output  screen

Input  process output

error
Input < output 1> error 2>
• Ls -l >> output.txt //output > overwrite
gedit output.txt >> append
• Ls –l test.sh 2>>error.txt // error
// output & error at same time
• Ls –l m.sh test.sh 1>> output 2>> error.txt
• Sort<file.txt //input
Default input
• tr ‘a-z’ ‘A-Z’ // transform
// change from lowercase letter to upper case letter
//change default input to be from file
• tr ‘a-z’ ‘A-Z’ < file1
PIPE
• Result of one operation is input to another operation
• Ex:
• Cat test | uniq //repeated sequentially only
• Cat test | sort | uniq //solve this problem
• Find / -name passwd | grep ‘bin’
Archiving and compression
• Archiving: Combining multiple files into a single file (archive).

• Compression: Making the archive use less storage space.

• In order to compress a folder or a bunch of files, you have to archive


them first and then you need perform the compression
Archiving
tar cf f.tar f1 f2 f3
cf= create file
var.tar= new archiving file
var = what archive
* Note that the archive name should always end in “.tar”
To extract
tar xf f.tar
xf=extract file
Compression files
gzip file1
Output file1.gz

Extract
gunzip file1.gz
• bzip2 file2

• Output file2.bz2

• Extract
• bunzip2 file2.bz2

You might also like