Is there any way to specify a field delimiter for more spaces with the cut command? (like " "+) ? For example: In the following string, I like to reach value '3744', what field delimiter I should say?
$ps axu | grep jboss
jboss 2574 0.0 0.0 3744 1092 ? S Aug17 0:00 /bin/sh /usr/java/jboss/bin/run.sh -c example.com -b 0.0.0.0
cut -d' '
is not what I want, for it's only for one single space.
awk
is not what I am looking for either, but how to do with 'cut'?
thanks.
Shorter/simpler solution: use
cuts
(cut on steroids I wrote)Note that
cuts
field indexes are zero-based so 5th field is specified as 4http://arielf.github.io/cuts/
And even shorter (not using cut at all) is:
Personally, I tend to use awk for jobs like this. For example:
I still like the way Perl handles fields with white space.
First field is $F[0].
If you want to pick columns from a ps output, any reason to not use -o?
e.g.
Minimum column width allocated, no padding, only single space field separator.
Pid and vsz given 10 char width, 1 space field separator.
Used in a script:-
One way around this is to go:
to replace multiple consecutive spaces with a single one.
As an alternative, there is always perl:
Or, if you want to get all fields starting at field #3 (as stated in one of the answers above):