Replace blank space by underscore in output of a command.
Hi All,
I want to replace the spaces in output of the following command with underscore ( _ ). Code:
# echo `date +%c` Code:
mv /home/vicky/maxima/logs /home/vicky/maxima/backup/logs.`date +%c` Code:
logs.Tue_21_Feb_2012_10:00:02_PM_IST |
Just use sed, it would be someting like sed 's/ /_/'
|
In BASH:
Code:
[me@comp ~]$ str=$(date +%c) |
Quote:
|
Thanks suicidaleggroll and unSpawn !!
|
Code:
dat=$( date +%c ) ; echo ${dat// /_} |
Quote:
We just need to make informative choice ! ;) Thanks uhelp ! |
Why not just manually format the date string as you want it to appear?
Code:
date "+%a_%d_%b_%Y_%I:%M:%S_%p_%Z" |
All times are GMT -5. The time now is 03:31 PM. |