How use CUT -d 'delimiter' is delimiter is a TAB?
How use CUT -d 'delimiter' is delimiter is a TAB?
:( Any ideas. Google is not helping much :( Best regards |
[ SOLVED ]
Quote:
MAN CUT is better and cuter than google cut. Code:
cat myfile | cut -f1 -s Code:
cat myfile | cut -f2 -s [ SOLVED ] |
Just for the next search user.
1) that solution correctly states that TAB is default delimiter for cut. 2) "cut -f1 -s myfile" works on its own, so cat invocation is redundant 3) Code:
cut -f1 -d\<TAB> Code:
cut -f1 -d"<TAB>" |
you can also use awk.
|
press "<CTR> v" then the "<TAB>" key
cut -d "<CTR>v <TAB>" |
Quote:
Oh thanks that a cool trick too. By the way if one type : Code:
ps aux | cut -f1 -s |
That's because word splitting makes the tab just ordinary whitespace to delimit parameters with. If you're really using Bash and not POSIX sh, then use $'\t' and Parameter Expansions. Or even play with IFS and use read:
Code:
IFS="." read h1 h2 h3 h4 <<< "127.0.0.1" |
Depending on the input format, sometimes using "tr -s ' '" will sqeeze extra spaces to a single space letting cut or awk work properly with a space as the delimiter.
example: ls -l | tr -s ' ' | cut -d' ' -f1,8- |
I use the awk
grep "833" session_20100321.log | awk '{ FS = "\t" ; printf(" %s %s\n", $5,$6); }'
|
If your looking to use with ps then:
Code:
ps aux | awk '{ print $1}' |
use this
cut -d$'\t'
|
When not in bash, use printf:
Code:
TAB=$(printf '\t') |
Quote:
|
All times are GMT -5. The time now is 02:57 AM. |