[NTLUG:Discuss] printing bash commands as output

Leroy Tennison leroy_tennison at prodigy.net
Thu Dec 6 23:52:56 CST 2007


There are situations where it would be nice to document a process and 
it's results, for example:

grep -v ^# /etc/inittab | tr -s \\n
			(with the following output)
si::sysinit:/etc/rc.d/rc.sysinit
l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
x:5:respawn:/etc/X11/prefdm -nodaemon

If I redirect the output of a bash script containing the above command 
pipeline to a file it will contain the results but I won't know what 
produced the results (the command pipline doesn't end up in the output 
file).  Is there an easy way to get both?



More information about the Discuss mailing list