Home > other >  How to find / \ (slashes) in a text file using shell script
How to find / \ (slashes) in a text file using shell script

Time:08-24

I have a file a.txt and I want to find slashes(/ and \ ) in it, so I used this command in my a.ksh script slashcheck=cat a.txt | grep '/'.

but how do I check for '' backward slash at the same time?

CodePudding user response:

Please try with:

cat a.txt | egrep '(\/|\\)'

CodePudding user response:

you can try this: cat a.txt | grep "[\/]"

CodePudding user response:

Try using a regular expression. You could use something like grep -E '[/\\]'.

Note that you will need two backslashes because the first one masks the second one.

Using squared brackets allows any character in these brackets to be a match.

The -E stands for extended and allows regular expressions to be used as seach patterns.

  • Related