bash - replace differently for different occurences with sed -
probably easy question not able figure out. how can utilize sed replace differently different occurrences?
i give example:
a="2012_01_01_05_05_05" desired output:
mod_a="2012-01-01 05:05:05" the thing know how sed is:
mod_a=`echo $a | sed 's/_/ /g'` i removing "_", transforming array, , create new look based on each element, less elegant.
simple sed solution:
sed 's/_/-/;s/_/-/;s/_/ /;s/_/:/g' <<< "$a" it replaces first , sec _ -, 3rd _ space , remaining ones :.
bash sed
No comments:
Post a Comment