Professional Documents
Culture Documents
Section 9
Section 9
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).
Extract
gunzip file1.gz
• bzip2 file2
• Output file2.bz2
• Extract
• bunzip2 file2.bz2