Hi All,
How can I match . (actual dot) using sed? Please help.
Thanks
Hi All,
How can I match . (actual dot) using sed? Please help.
Thanks
You need to escape it with a \
Look at this.
sh-2.05b$ cat jing.txt
test
.
test.match
sh-2.05b$ sed -n -e '/\./p' jing.txt
.
test.match
Thanks vino.
But this doesn't work. I am looking for /./* (one or more of /./ and replace with a single /./
I tried dereferencing . and /
it doen't work. Please help.
Thanks
This is going to be a confusing regex.
sed -e 's#\/\.\/\{1,\}#\/\.\/#g'
vino
Please see below:
cat 1 gives:
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
sed -e 's#\.\{1,\}#\.#g' 1 > 2
now see cat 2
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
It is not working.
Yes the previous solution will not work.
But this should work
sh-2.05b$ cat jing.txt
test
/./
test/.//.//./match
sh-2.05b$ sed -e 's#\(\/\.\/\)*#\1#g' jing.txt
test
/./
test/./match
vino
cat 1
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
sed -e 's#\(\/\.\/\)*#\1#g' 1 > 2
cat 2
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
/.//.//./
It is not working. Is there is special reason why this doesn't work?
Possibly your sed version could be the culprit in this case.
I am using this sed
sh-2.05b$ sed -V
GNU sed version 4.0.7
vino
Vino,
See below:
sed -V
sed: illegal option -- V
???????

Not strictly speaking what you asked for, but should do what you want.
sed -e 's#/\./[./]*#/\./#g' file