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

All Questions

Tagged with
0 votes
1 answer
79 views

How to use grep string that has double quotes in it

So I'm running a simple alias called vpn which runs a command and has an output, which I put into a .txt file. If interested to what exactly then here is the alias alias vpn="docker exec -it ...
Arelius's user avatar
  • 73
-1 votes
1 answer
42 views

I can't grep some inputrc string

bind -p |grep -E "\\e.\":" work but bind -p |grep -E "\\e\\C-.\":" don't work I tried a lot of combination
user3634569's user avatar
-1 votes
3 answers
94 views

How to use a variable in a command inside of a bash file

I use this command directly on our redhat linux server 8.8 and it's working correctly and I get the result I want: grep '01-FEB-2024' /u01/app/server1/listener_scan/trace/listener_scan.log | awk '{ if ...
TimLer's user avatar
  • 101
3 votes
1 answer
7k views

Grep pattern that has double quotes and variable substitution surrounded by single quotes

So, Let's say I have the following pattern: Thisisatest="1" in a file called file. And I want to match the exact string above but for whatever reason, I choose to loop over some numbers ...
Nordine Lotfi's user avatar
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....
jxhyc's user avatar
  • 181
3 votes
1 answer
2k views

prevent single quotes in bash script

I have a bash script that's just a shortcut to the grep command. I call it like this: stx -p /var/www -t 'my text' This would run this command: sudo grep -rinI /var/www -e 'my text' I'm trying to ...
raphael75's user avatar
  • 733
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 ...
bit's user avatar
  • 1,116
1 vote
1 answer
325 views

grep not working when I enclose the directory in double quotes

When I do something like this: grep "hello" /home/paul/* It works. But when I do something like this: grep "hello" "/home/paul/*" grep display the error: grep: /home/paul/*: No such file or ...
paul's user avatar
  • 495
-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
4 answers
5k views

How do I invoke jq inside awk?

Essentially I have a file.log as follow blah blah blah blah Hello world | {"foo": "bar"} blah blah Hello earth | {"foo1": "bar1"} Now my goal is to write some shell commands to have desire output ...
Luong Ngoc Son's user avatar
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 ...
vfclists's user avatar
  • 7,619
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
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 ...
user217282's user avatar
1 vote
3 answers
945 views

Why doesn't grep return what I expect when I use single quotes

I have a file with the below contents: sh-4.2$ cat file1 example of multiple pattern this is an example of multipole sorry multiple pattern matching using grep so the example is the file itself -...
Pankaj Pandey's user avatar
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 ...
Iamnoone's user avatar
-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>" * # ...
pokche's user avatar
  • 103
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
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 ...
Shar Hunter's user avatar
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?
tmpbin's user avatar
  • 783
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 ...
faimer's user avatar
  • 21
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 ...
romil gaurav's user avatar
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 ...
BluVio's user avatar
  • 155
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 ...
Katz's user avatar
  • 1,071
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 ...
Leo Simon's user avatar
  • 453
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 ...
Sudhish Vln's user avatar
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 ...
kevinarpe's user avatar
  • 687
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 ...
Leo Simon's user avatar
  • 453
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 ...
user avatar
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 ...
Charybdis's user avatar
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. $ ...
fedorqui's user avatar
  • 7,961

15 30 50 per page