Created
June 21, 2016 15:50
-
-
Save yosske/4cfbcbab63f8f3dd9f24b38f4acd7757 to your computer and use it in GitHub Desktop.
Like echo, but in the --color that grep uses when that option is given
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#handle no input - just fire echo and exit | |
if [ "$#" -eq 0 ]; then | |
echo | |
exit | |
fi | |
#concat params like echo does | |
str="$1" | |
shift | |
for var in "$@" | |
do | |
str=$str" "$var | |
done | |
#use a match all grep to with --color to color the output | |
echo "$str" | grep --color -o ".*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment