0% found this document useful (0 votes)
8 views9 pages

Section 9

Pipe and redirection allow the output of one command to serve as input to another. Pipes use | to connect commands while redirection uses < and > to redirect input and output. Archiving combines multiple files into a single archive file using tar while compression compresses the archive file to reduce storage size using gzip, bzip2, or other tools.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

Section 9

Pipe and redirection allow the output of one command to serve as input to another. Pipes use | to connect commands while redirection uses < and > to redirect input and output. Archiving combines multiple files into a single archive file using tar while compression compresses the archive file to reduce storage size using gzip, bzip2, or other tools.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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