All Questions
31
questions
1
vote
1
answer
2k
views
grep: use square brackets to match specific characters
So I am experimenting with the power of grep using this resources
The problem I am currently encountering is that it doesn't seem to work as I intended. so I have an demo.txt file that contains foo....
5
votes
2
answers
26k
views
How do I grep multiple patterns from a pipe
I want to find three patterns in a list. I tried typing
$ pip3 list | grep -ei foo -ei bar -ei baz
but the shell throws a broken pipe error and a large Traceback.
How do I grep for multiple ...
4
votes
3
answers
15k
views
How can search for both single quotes and double quotes in a grep search?
When I do a search bindkey in the zsh plugins directory for key conflicts I get responses from both the .zsh script files and .md files, and some of the zsh readme files use a double quote in the ...
5
votes
4
answers
10k
views
Backslash usage in different commands
I have been trying to get a better understanding of how backslash is used in certain commands. I understand its usage for escaping special characters (Such as echo 'that'\''s no moon'
), but the ...
0
votes
4
answers
2k
views
grep syntax for searching strings with single-quotes?
So, I have a .js file as below and I am trying to search with the below grep pattern. I am not sure what mistake I did but it does not give any output even though the file has that pattern. What ...
-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>" * # ...
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 ...
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 ...
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 ...
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.
$ ...
3
votes
4
answers
20k
views
Wildcards for filepaths aren't working in grep [duplicate]
I need to grep words like these:
ABC-DEF
AB2-DEF
AB3-DEF
AB-DEF
So I was trying:
grep AB*-DEF
grep -w -AB*-DEF
grep -w AB*DEF
But neither of them are working.
2
votes
1
answer
14k
views
grep: Syntax error near unexpected token `('
I have this problem: I'm looking for a string inside file .
Syntax is:
grep -E ‘( ^ | [[:space:]] )[A-Z]{2}[[:digit:]]{2}((- | [[:space:]] )[[:alnum:]]{4}) {3} ’ (filename)
When I run this ...