Question

I need to change every occurrence of ! to : as field separators in a group file.

sed 's/!/:/g' filename > newfilename 

But I get the error /: Event not found?

Was it helpful?

Solution

You are using csh so the ! is being interpreted to fix this escape the ! or just use bash:

sed 's/\!/:/g' file > outfile

With csh the ! used for command history reference and it works even inside a pair of apostrophes ' or quotation marks ", unless escaped with a backslash \.

OTHER TIPS

I would verify the file existence and file permissions maybe, because the sed line works just fine:

[root@hacklab5 ~]# cat /tmp/sed.org 
dewed!Ddew!de
dewwe!ds!dewe
[root@hacklab5 ~]# sed 's/!/:/g' /tmp/sed.org 
dewed:Ddew:de
dewwe:ds:dewe
[root@hacklab5 ~]# sed 's/!/:/g' /tmp/sed.org > /tmp/sed.new
[root@hacklab5 ~]# cat /tmp/sed.new 
dewed:Ddew:de
dewwe:ds:dewe
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top