Amir Rachum
Amir Rachum

Reputation: 79735

Replacing all commas with spaces - S/R with a Unix Command?

I'm looking for a Unix command that will allow me to search/replace in a file - I need to replace all commas in a certain file with spaces. I need to do this in a script and I'm looking to avoid parsing/reading the file line by line. Is there a simple unix command that will allow me to do this?

Upvotes: 18

Views: 46267

Answers (3)

Tms91
Tms91

Reputation: 4234

I would suggest awk, in case you also need to expand your command with some conditionals (take a look here)

awk '{gsub(",", " "); print}' file_path > resultfile_path

Upvotes: 0

khachik
khachik

Reputation: 28703

sed 's/,/ /g' filename >resultfile

Upvotes: 26

Konerak
Konerak

Reputation: 39773

You can use awk, sed, vi, ex or even Perl, PHP etc ... depends what you are proficient with.

sed example:

sed -i 's/,/ /g' filename_here

Upvotes: 7

Related Questions