I know this question has already been asked but no of the solution I've found worked for me! I have a program that has an output like this:
COUNT|293|1|lps
I'm interested in having the second field however no one of these tries worked:
./spawn 1 | cut -d '|' -f2
./spawn 1 | cut -d \| -f2
./spawn 1 | awk -F "|" '{print $2}'
./spawn 1 | awk 'BEGIN{FS="|"} {print $2}'
./spawn 1 | sed 's/|/;/g'
./spawn 1 | sed 's/\|/;/g'
But the output is always the same:
COUNT|293|1|lps
Is there a bug somewhere in bash? I would be surprised, the results is the same on my Linux host and on my embedded device using busybox's ash! Any pointer is strongly appreciated!
EDIT My fault, the output was in stderr ... ._.
./spawn 1 2>&1 | cut -d '|' -f2
4615
Sorry for ennoying!
./spawn 1
is printing to standard error instead of standard output? Does./spawn 1 2>&1 | cut -d '|' -f2
work, for example? – Kittrell