3

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?

3 Answers 3

7
echo -n "0:" ; asterisk ......
Sign up to request clarification or add additional context in comments.

1 Comment

This strikes me as the "most correct" answer, but it would be better if it showed OP enough context to see it working as a single compound command. IOW wrapped in either curly braces for redirection or $() for capturing.
3

roll it all into

asterisk -rx "core show calls" | awk '/active/{print "0:"$1}'

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.