create a nicely formatted example of a shell command and its output

example() { echo "EXAMPLE:"; echo; echo " [email protected]"; echo; echo "OUTPUT:"; echo ; eval "[email protected]" | sed 's/^/ /'; }
Shell function which takes a bash command as its input, and displays the following formatted output: EXAMPLE: command OUTPUT: output from command
Sample Output

    example ls -l


        ls -l
        total 0
        -rw-rw-r-- 1 bartonc bartonc 0 Nov 10 13:58 a
        -rw-rw-r-- 1 bartonc bartonc 0 Nov 10 13:58 b
        -rw-rw-r-- 1 bartonc bartonc 0 Nov 10 13:58 c

By: bartonski
2019-11-10 19:08:23

What Others Think

You need to add some color to this.
renich · 34 weeks and 2 days ago
Thank you so much for sharing with us example of shell command and its exact output. I surely share it with whom I serve IT cv writing service at very affordable price.
LaurendeSouza · 12 weeks and 4 days ago
I appreciate an author for providing here best example of shell command and its output. Keep it up! Regards, Ida.
IdaWallace · 11 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: