Quantcast
Channel: Frequently Asked Questions About Linux / UNIX » sed find and replace
Viewing all articles
Browse latest Browse all 5

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

$
0
0
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 Outputs: 01/20/12_16:10:42
I'd like to replace / and : with _. I'm aware of the following sed command:
sed 's/\//_/g > s/:/_/g' Outputs: 01_20_12_16_14_09
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?

Read answer to: "Linux / Unix: Sed Substitute Multiple Patterns [ Find & Replace ]"

Tweet this    Share on Facebook


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images