Adding a tab character before external script output

Viewed 2994

So, i've got a shell script to automate some SVN commands. I output to both a logfile and stdout during the script, and direct the SVN output to /dev/null. Now i'd like to include the SVN output in my logging, but to seperate it from my own output i'd like to prepend a \t to each line of the SVN output. Can this be done with shell scripting?

Edit Is this something i could use AWK for? I'll investigate!

Edit So, using AWK seems to do the trick. Sadly i can't get it to work with the svn commands though.

svn add * | awk '{ print "\t"$0 }'

Outputs without the prepended tab character. But if i run for example ls

ls -l | awk '{ print "\t"$0 }'

The directory is listed with a tab character in front of each line.

Edit Thanks @daniel! I ended up with this

svn add * 2>&1 | sed 's/^/\t/'

Might aswell note that awk works well for this, when used correctly

svn add * 2>&1 | awk '{print "\t"$0 }'
1 Answers
Related