Tagged Questions
2
votes
3answers
102 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
...
7
votes
2answers
217 views
“grep -r foo *” vs “grep -r foo .”
When using grep -r you could search in all files with either * or .
and it seems to return the same thing but is it really the same?
Let's say I search for "foo", then I could write
grep -r foo *
...
1
vote
1answer
525 views
Difficulty making a regular expression to find at least 2 occurrences of a character in a file
I have a file containing random codes. Each code has ten characters in it, and I am trying to grep codes in the file that have at least 2 occurrences of a character. I am doing this:
grep DD* ...
6
votes
1answer
7k views
Bash: assign ls | grep to a variable and echo it with a string
I want to assign the result of an expression to a variable and concatenate it with a string, then echo it. Here's what I've got:
#!/bin/bash
cd ~/Desktop;
thefile= ls -t -U | grep -m 1 "Screen Shot";
...
5
votes
4answers
1k views
Find a string only in a specific file inside subdirectories
Let's say I need to find the function GetTypes() in all C# source file (.cs) the directories/subdirectories.
I used grep -rn GetTypes *.cs, but I got an error with grep: *.cs: No such file or ...