This command is useful if you want to copy the output of a series of commands to a file, for example if you want to pastebin the output from ‘uname -a’, ‘lspci -vvv’ and ‘lsmod’ for video driver trouble-shooting on your favorite Linux forum.
‘log’ takes all the following arguments as a command to execute, with STDOUT sent to /var/log/user.log. The command is echoed to the log before it is executed.
The advantages of using logger (as opposed to appending output from commands to a file) are 1) commands are always appended to the logs… you don’t have to worry about clobbering your log file accidentally by using ‘>’ rather than ‘»’ 2) logs are automatically cleaned up by logrotate.
The following functions allow you to mark the start and end of a section of /var/log/user.log.
printlog will print all lines between $LOGMARK.START and $LOGMARK.END, removing everything that is prepended to each line by logger.
Caveats: I’m sure that those could use some cleanup and error checking… there are unchecked dependencies between printlog and endlog, as well as between endlog and startlog.
It might be useful for ‘log’ to also send stderr to logger as well.
* View this command to comment, vote or add to favourites * View all commands by bartonski
by David Winterbottom (codeinthehole.com)
- chronic – runs a command quietly unless it fails (yjl.im)
- Display a List of Recently Installed Software Packages in Ubuntu (kansasdad.blogspot.com)
- Corner of the Circle: Linux Directory Structure (File System Structure) Explained with Examples (thegeekstuff.com)
- imabonehead: Houcem HACHICHA’s Blog: My top ten shell/bash tricks! (houcemhachicha.blogspot.com)
- Display a List of Recently Installed Software Packages in Ubuntu (helpdeskgeek.com)
- 2010/12/26 Empty a file
- 2010/11/23 intercept stdout/stderr of another process or disowned process
- 2010/11/09 Print all environment variables, including hidden ones
- 2010/08/13 tee to a file descriptor
- 2010/05/16 Downloading all related videos from youtube with youtube-dl