Reputation: 43
I am looking to run this command
asterisk -rx "core show calls" | grep "active" | cut -d' ' -f1
it will output a number but I want it to append a "0:" at the beginning so the output looks like this
0:{output from command}
any ideas?
Upvotes: 3
Views: 13408
Reputation: 23394
roll it all into awk
asterisk -rx "core show calls" | awk '/active/{print "0:"$1}'
Upvotes: 3
Reputation: 10434
By using sed
on the end:
asterisk -rx "core show calls" | grep "active" | cut -d' ' -f1 | sed 's/^/0:/g'
by ^ in regular expression you indicate to put 0: in the beginning. You can add any text this way. Also you can add it in any other place inside a string, not only in the beginning.
Upvotes: 0