What would be the best way to replace all instances of...
09/26/2005
with
20050926
There are no spaces between the the date and the preceeding and following data. example lines looks like...
snp01|NAME/OF/A/GROUP|09/26/2005081343|502
the 081343 is the time without colons.
Thank you.
ruby -pe'sub(%r!(\d\d)/(\d\d)/(\d{4})!,"\\3\\1\\2")'
Could you explain that more...
I'm using the korn shell. How would I use ruby inside a korn script.
I tried using the sed command, but it's doesn't do anything...
sed -e 's/$date/$newDate/g' $ofile > test.txt
sed -e "s#$date#$newDate#g" $ofile > test.txt
that sed command is not working for me...
I was going to try using this to do it, but it won't pass the variable to it...
/bin/echo '%s/^/"$newDate "/g\nwq!' | ex - $ofile
Please check one again, I tried sed command suggested above works perfectly.
Here is the test:
>more g
09/26/2005
>echo $old_date
09/26/2005
>echo $new_date
20050926
>sed -e "s:$old_date:$new_date:g" g
20050926
The ex command is not working because the subsitute pattern will fail becuase of backslashes in variable itself.
rishi