Linux / Unix: Sed Substitute Multiple Patterns [ Find & Replace ]

last updated in Categories

I‘m using the date +’%D_%T’ to store Unix system date and time in a shell variable called $_now:

_now=”$(date +’%D_%T’)”
echo $_now


I’d like to replace / and : with _. I’m aware of the following sed command:

sed ‘s/\//_/g
> s/:/_/g’ <<<"$_now"


How do I specify two pattern within the same sed command to replace | and : with _ so that I can get output as 01_20_12_16_10_42?

HowTo: UNIX Set Date and Time Command

last updated in Categories

I recently noticed that one of my UNIX servers was about 4 hours behind the correct time. I wanted to correct the date and time manually. How do I set date and/or time under UNIX operating systems using command line options?

UNIX / Linux: Increment The Date

last updated in Categories ,

I want to increment the date under UNIX or Linux operating system while writing shell scripts. For example Apr/27/2011 should be incremented as Apr/28/2011 and so on. How do I increment a date in UNIX or Linux shell?