Cut
cut -c 1-7 f1 will output the first 7 characters in each line of file 'f1'.
cut -c 2,4-7,10- f1 will output the character 2, characters 4 – 7, characters 10 until the end of line in each line of file 'f1'.
cut -f 1,4,5 f1 will output 'fields' 1, 4 and 5 in file 'f1'. The fields are assumed to be separated by tab in 'f1'.
cut -d ' ' -f 1,4,5 f1 will output 'fields' 1, 4 and 5 in file 'f1'. The fields are assumed to be separated by a single space in 'f1'.
Sed
Let's make a test file
ls -l /etc > testsed
"d" means delete
sed '1,4d' testsed
sed '/yum/d' testsed
sed '/yum/!d' testsed
"s" is replace, -n means hide the other output, p is display
sed -n 's/pass/xxxxx/p' testsed
Awk
Make another file to test awk
ps aux > testawk
Show column 11
awk '{print $11}' testawk
awk '/sbin/{print $2,$11}' testawk
Labels
訂閱:
張貼留言 (Atom)
History
-
▼
2010
(37)
-
▼
1月
(9)
- Recommended application and installation for new U...
- Linux - Compression and Uncompression Example
- Change process priority - nice and renice
- Checking system status
- Linux command - cut, sed, awk
- ps aux 各欄位的意義
- Fine tune your VM - Extend vm disk size in Linux
- Fedora 12 enable root login in GUI
- editor - vi
-
▼
1月
(9)
沒有留言:
張貼留言