All Questions
59
questions
-1
votes
1
answer
904
views
How to grep and treat meta character as normal character? [closed]
I am trying to recursively find some pattern which contains meta character.
Pattern that I searching for is template <int N>
I have tried :
grep -F -lir "template <int N>" * # ...
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=...
8
votes
5
answers
33k
views
How to find lines that begin with **
I need to find if any lines in a file begin with ** .
I cannot figure out how to do it because * is interpreted as a wildcard by the shell.
grep -i "^2" test.out
works if the line begins with a 2 ...
9
votes
1
answer
1k
views
Why does `grep fil*` fail?
I found echo file|grep fil* fails, but echo abcd|grep abc* succeeds.
I don't understand it, can someone explain?
1
vote
1
answer
15k
views
grep with variable in a variable
I want to filter the svlog file by date and split the result by the space,
so when i enter the date, it didn't work for me,
please refer to the script that I wrote below, the problem was in this ...
2
votes
4
answers
6k
views
Why does the grep command ignore the period in the search string?
The command that I am using:
find . -type f -name "*.sql" -exec grep -i -l 'schema_name.' {} +
What I want to search is all the files which contain schema_name..
But the find command is ignoring the ...
3
votes
1
answer
3k
views
cshell alias: How to use nested single quotes(') in in cshell alias
I am trying below alias in cshell:
alias sll 'ls -l \!* | grep -oE '[^ ]+$' | paste -s | xargs ls -l'
For this CSH says, Illegal variable name.
If I use \$, alias will be set without any error. But ...
1
vote
1
answer
3k
views
What does a backslash represent when searching for decimals
I want to understand what the backslash represents in this command. grep "\.900983" table
I know what the command does, it searches for the 900983 value in table, I'm just not sure of the purpose of ...
1
vote
1
answer
8k
views
Passing a variable argument to egrep in a bash script
I have a script, myScript, which is trying to egrep the script argument in a file. Somehow variable expansion isn't working properly with the egrep command. I believe I've isolated the problem ...
2
votes
1
answer
1k
views
bash regex: asterisk gives ambiguous search results with grep
I am using a simple text file to test the * meta-character through grep.
The text file is as below:
1
11
111
1111
11111
111111
d
da
daa
daaa
b
bc
bcc
bccc
Now when I search digit 1 using grep like ...
3
votes
2
answers
2k
views
How to escape metacharacters for egrep like metaquote from Perl?
Perl has a function called metaquote() to escape all special characters for a regular expression.
Is there an equivalent technique for egrep?
Example: If I am searching for the string abc.def.ghi, I ...
2
votes
1
answer
249
views
In bash, grep for a line beginning with \, and assign the result using backticks
In bash, I'm trying to grep a file for a line beginning with a \, and return the result using backticks.
For example:
echo \\Hello > myFile
out=`cat myFile | grep '^\\Hello'`
echo $out
returns ...
4
votes
1
answer
1k
views
Match pattern \\\" using grep
I have a json string inside json. This got encoded multiple times and I ended up with many escape backlashes: \\\".
The much shortened string looks like,
'[{"testId" : "12345", "message": "\\\"the ...
2
votes
3
answers
352
views
grep .* returns results from .bash_history and complains about
I'm new to Linux and so far I've been playing around with some utilities, specifically the grep utility. I decided to create a new file (aptly called 'newfile') with the following content:
Lady of ...
15
votes
2
answers
18k
views
How to use multiline as group-separator in grep?
In grep you can use --group-separator to write something in between group matches.
This comes handy to make it clear what blocks do we have, especially when using -C X option to get context lines.
$ ...