vendredi 30 janvier 2015

Find the line number which contains the pattern with custom delimiter


As in example I'm trying to get line numbers which contains the pattern. My pattern contains slashes so I wanted to add custom delimiter.


This simple one works:



sed -n '/file/=' temp.txt


Using delimiter for string replace works too:



sed 's|file|gile|' temp.txt


but when I want to add delimiter to first example it doesn't:



sed -n 's|file /etc|=' temp.txt


I know I can escape slashes but I would prefer to add custom delimiter. Any idea how to fix my command?



Aucun commentaire:

Enregistrer un commentaire