All Questions
2,584
questions
-1
votes
3
answers
55
views
How to use grep in specific case? [closed]
How to extract part of the search with grep.
Example: I would like to extract lines with "bc" in them
but not lines containing "abc".
My not-so-elegant solution is:
cat file.txt | ...
0
votes
1
answer
24
views
emacs windows gitbash and cmd.exe shells
I have Emacs for windows. I have GITBASH for windows.
My goal: How can I get Emacs to use the GITBASH version of GREP, when I use M-x grep?
NOTE: For various reasons I cannot put "C:\Program ...
0
votes
1
answer
35
views
using grep with a variable containing xml-tags [duplicate]
I have a script that is trying to find a line in a text file. It could be completely alphanumerical, but it's also possible that it contains special characters, mostly < and > as it's sometimes ...
-1
votes
3
answers
77
views
Optimise text file statistics calculation by combination of grep, awk, cut
My goal is to calculate statistics from the file that contains the following lines:
2024-05-08 11:02:58,731 INFO o.a.j.a.J.Some check: Closest Day: Wed, New quantity for [email protected] is: 1
...
-5
votes
2
answers
54
views
(LINUX) use echo and grep to delete multiple files
I have 4 files in my current directory: '#cos#', ab.txt, cos~, file.txt. I want to delete all files with the word "cos" in them, which just also happen to be the only words with the letters '...
1
vote
3
answers
158
views
Get the count of unique words in a file using grep and wc
need command to find the count of unique words in a file using grep
Tried using grep along with uniq and sort but need to find a way to use only grep and wc commands.these are the two ways in which am ...
-1
votes
1
answer
42
views
How to grep a specific data
I want to grep python extensions with their names in a large data of words and sentences, and I tried with find and grep commands but I couldn't do that. Can anyone tell me what should I do?
By the ...
0
votes
0
answers
46
views
Confused about why the regex pattern does not works [duplicate]
I'm using npm ls -a which gives the following ouput:
└─┬ [email protected]
├── [email protected]
└── [email protected]
I'm trying to extract all the dependencies and store it in a file with the following ...
1
vote
3
answers
46
views
grep expression behaving weird (unix/mac) while reading a conf file
What's going wrong in below grep expression, appreciate any help.
$cat foo.txt
## not to be read
; this one too and next one also coz it has sapce
first_var= first_val
second_var=y
second_var=yes
Now ...
1
vote
1
answer
72
views
find and grep - Suppress terminated by signal 13
If I want to find only first match of command grep I use this:
find -name "*.jar" | xargs grep -al myText | head -1
And it's work just fine.
But it's also show the next message:
xargs: grep:...
0
votes
0
answers
51
views
How to execute a command saved in a variable in linux and save the result in a new variable [duplicate]
I am executing a series of commands and I hope to achieve the following effect:
I need to echo the command before the execution.
Execute the command and save the results to a bash variable, including ...
1
vote
1
answer
40
views
grep with exclude pattern in shell
text file has below lines named 'log'
--- [n-event-group-3] action
--- [n-event-group-8] action.service
--- [n-event-group-2] essing.service.
--- [n-event-group-10] service.
--- [ost-stats-event] host....
0
votes
1
answer
314
views
"Error: no such file or directory" even when the command works file outside an script
I am writing an script that runs the command:
podman ps | grep -i healthy | grep netbackup | awk '{print $1}'
This commands works fine from the shell. However, it fails with "Error: no such file ...
0
votes
0
answers
62
views
when using "pgrep" in shell script, showing 2 pids including real process's pid.(terminal output only shows 1 pid - real process's pid.)
I use CentOS 7.7 on my linux server.
below is my terminal output :
# pgrep -f 'process_name'
19737
after checking the output, I made shell script like below :
#!/bin/sh
test_pid=$(pgrep -f '...
0
votes
1
answer
52
views
Can't capture output of find + grep in Bash [duplicate]
I'm hitting my head against the wall here with this...
I'm trying to create a simple script that loads a file as an array, and searches for each line through files whether there is a match.
If a ...