Arun
Arun

Reputation: 1220

Unix Find & Replace Issue

I have a pretty huge .csv file with the date at column 3 ( Example: 11/17/2015) and i need to replace with the date format as 2015-11-17. I tried doing using:%s/\<11/17/2015\>/2015-11-17.But couldn't see the change. Any suggestions on how to do this?.

Upvotes: 0

Views: 31

Answers (2)

David
David

Reputation: 404

I assume you are using vim:

:%s/11\/17\/2015/2015-11-17/g

You can do this also with sed without opening the file:

sed -i 's/11\/17\/2015/2015-11-17/' somefile.csv

Upvotes: 1

SMA
SMA

Reputation: 37023

Try to escape backslash like:

echo "11/17/2015" | sed 's/11\/17\/2015/2015-11-17/g'
2015-11-17

Upvotes: 1

Related Questions