Reputation: 65
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
?
Upvotes: 6
Views: 7922
Reputation: 85795
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 \
.
Upvotes: 13
Reputation: 5931
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
Upvotes: 0