1

I'd like to print command output along with its input. For example for such call as

echo "Hello world" | wc -c

I want the following output:

12,Hello world

Is there any way to do this using standard Unix (or GNU) tools?

Petr Razumov
  • 151
  • 6
  • Would be good to know if this is for a specific shell or if it should be shell agnostic. Some shells namely have good ways to deal with this. – ojs Jan 10 '17 at 12:57

2 Answers2

1

tee and paste solution:

echo "Hello world" | tee >(wc -c) | tac | paste -s -d, -
12,Hello world
Petr Razumov
  • 151
  • 6
0

A possibility (I think there should be better ones):

echo `echo "Hello world" | wc -c` ",Hello world" | sed 's/ ,/,/g'