Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

-2 votes
2 answers
3k views

Grep not working with variables, even with quotes

name=$(echo "$FILENAME" | grep -E '*\.(eng|por|pt-BR)\.*') Why this line doesn't work? if I do echo "Test (2013).1080p.por.mkv" | grep -E "*\.(eng|por)\.*" It works, I tried with "" without " and ...
Freedo's user avatar
  • 1,295
4 votes
3 answers
13k views

Escape [ in grep

I read strings from stdin and I want to display the users that match the strings. Problem is, if the user inputs the character '[', or a string containing it. grep -F does not work because the line ...
Tigrex's user avatar
  • 53
7 votes
1 answer
1k views

How to extract the string between two \n in a file

I have a file with pattern <span class="WebRupee">Rs.</span>\n29\n<br/><font style="font-size:smaller;font-weight:normal">\n3 days\n</font></td>, <td class=...
penta's user avatar
  • 195
2 votes
1 answer
2k views

Regex works in shell but not through Perl script

I'm having trouble executing a Perl script through the Unix shell using Perl's system command. I've had more complex regex commands I had to adjust accordingly to convert from Unix to Perl, and they'...
lkisac's user avatar
  • 259
17 votes
2 answers
24k views

Why do I have to escape a "dot" twice?

I know that we can escape a special character like *(){}$ with \ so as to be considered literals. For example \* or \$ But in case of . I have to do it twice, like \\. otherwise it is considered ...
Registered User's user avatar
2 votes
3 answers
4k views

Very strange behavior with grep and IFS

I'm having trouble using grep, the returned results are "n-empty", I mean without the 'n' character... This is the script sample : OLDIFS=$IFS IFS="\\n" i=$(grep -ril $1 *) echo $i IFS=$OLDIFS I ...
Benj's user avatar
  • 123