Match multi-tab
replace all of 1 or more TAB with write space in file, it seems "+" doesn't work in sed cmd.
$ sed 's/[ ][ ]*/ /g' file
Unknown write space number
To get the trailer number 3 from a file like this:
cat test.dat
A.B.C.D.E.A.B.C.D.E A.B.C.D.E.A.B.C.D.E A.B.C.D.E.A.B.C.D.E COUNT 3
The write spaces between COUNT and the number 3 are unknown.
Use:
tail -1 test.dat | cut -d' ' -f2- | tr -d ' '
tail -1 test.dat
COUNT 3
tail -1 test.dat | cut -d' ' -f2-
3
tail -1 test.dat | cut -d' ' -f2- | tr -d ' '
3



评论 (1)
晕,这么复杂,本来想学一下,没想到这么难,算了
Posted on November 4, 2007 01:39