Here is an example to provethe same:
ps -u $LOGNAME tr -s " " : cut -d: -f
The above script line can beused to extract a column fromthe output of a ps command for a particular user ($LOGNAME).
A unique blog for Unix, Linux based Tips, tricks and Shell Scripts. This is intended to be one-stop Information Center for all your Unix, Linux needs.
When you write a shell scripts you need to create filename with date in it. For example instead of log file name "traces.log", you can create a filename called "traces-Jun-27-8.log".
The date in file will make it easy to find out all logs or reports. You can display the current date and time in the given FORMAT using date command. If you just type date command it will display in standard FORMAT:
$ date
Output:
Fri Jun 27 11:43:25 IST 2008
To display date in MONTH-DAY-YEAR format you need to use date command as follows:
$ date +"%b-%d-%y"
Jun-27-08As you can see I have used FORMAT as follows
date +"FORMAT"
Where, FORMAT can be any one of the following:
First obtained date:$ NOW=$(date +"%b-%d-%y")
Create a file with date in filename$ LOGFILE="log-$NOW.log"
Display filename:$ echo $LOGFILE