Questions tagged [grep]
grep is a command-line utility that is used for searching text.
721
questions
0
votes
0
answers
30
views
moving multiple files
i have a downloadsfolder that contains 9 items backup.sh ,bestanden.sh, tara.tar.gz, nmap.tar.bz2, demo11.zip, contract.pdf, cleaning.pdf, GNU-linux.jpg and video.mp4.
these have to get sorted in the ...
0
votes
1
answer
35
views
Why egrep outputs two blank lines but "redirecting to file" produces actual text
I'm using Ubuntu 20.04.4 with stock grep version 3.4.
I find something I cannot explain, please help.
[/dev/pts/0(xterm-256color) 2023-04-04 10:28:01 ERR:0]
[chj @Ub20cppdev ~/test]
$ cat input3l.csv
...
2
votes
2
answers
157
views
Running grep via GNU parallel
How can I make searches with grep on a large number of files run faster? My first attempt uses parallel (which could be improved or other approaches suggested).
The first grep simply gives the list ...
2
votes
3
answers
575
views
Passing multiple file patterns to grep
I have a sequence of search patterns stored in a bash array (ptrn), which I want to pass to a grep command. How can I do it?
ptrn=("FN" "DS")
for fl in "$@"; do # ...
1
vote
1
answer
31
views
grep PCRE still greedy
I'm searching a multi-line text file and want to match a string from a certain word until the first match of another word:
start
word1
word1
word1
word1
end
word2
word2
word2
start
word3
word3
word3
...
0
votes
1
answer
39
views
How do I pipe grep commands with a "-" without it being interpreted as an option? [duplicate]
I'm using a Kali Linux distribution and I'm trying to learn how to use the | character for piping using grep. If I wanted to search the hashcat help file for what -a means for example, how would I do ...
0
votes
1
answer
49
views
How to extract channel names from YouTube subscription source file
I have an html source file of YouTube subscriptions, and want to extract just the /user/CHANNELNAME parts into a separate file.
The source file (browser > youtube.com > subscriptions > manage ...
-1
votes
1
answer
116
views
What's wrong with 'grep' command in Ubuntu-18.04.6?
I enjoyed 'grep' for decades but I left Linux years later and I came back again, finding 'grep' works different from before. I checked its usage from web and confirm my memory is not corrupted.
I am ...
0
votes
1
answer
50
views
How to Categorically Relocate Records Using Grep
I need to parse a file containing records beginning with a keyword and
selectively write those records to separate category files. After this
is done, the records that were extracted need to be ...
-3
votes
1
answer
143
views
Trying to pipe, redirect, or use `grep` or similar commands in a sftp environment
How can i limit the ls command output to display only the most recent X number of files created within a folder in a sftp environment ?
tail, grep, or > >> (redirect commands) are not ...
1
vote
1
answer
149
views
grep and awk commands not returning or storing output to the variable
I have a (users.csv) file containing a list of id's of all employees. I need is to loop through this file for each employee, search if it exists in backup.txt file using grep and store the output in a ...
-1
votes
1
answer
33
views
Trying to remove all text except for IPs, data is in a file I downloaded
This is what I normally use to normalize the data, but it is not working. I need to keep only the IPs, one IP per line, and everything else must go. I'm using this in an .sh shell script.
grep -oE '[...
0
votes
2
answers
40
views
why grep with regex command not working on Ubuntu
I wanted to know the packages which are installed and starting with mos then below command not working.
dpkg -l | grep ^mos*
0
votes
1
answer
54
views
How to grep on a file owned by nobody?
I have a /etc/openvpn/test.txt file with the following status and a single word content "test":
-rw-r--r-- 1 nobody root 173 Jan 25 21:48 test.txt
When I try to grep on it I get a ...
0
votes
1
answer
75
views
ps aux | grep command doesn't display categories
When I pipe to grep after a ps aux command it isn't showing the categories at the top of the list (USER, PID, %CPU, %MEM, etc) Is there something I can do about this?
ps aux --sort -rss | grep $USER | ...
1
vote
3
answers
144
views
Couldn't able to store a output of awk command
I have been trying to print git clone progress on more minimalistic way for my project.
Aim
Instead of printing a whole git clone output on screen
remote: Enumerating objects: 1845678, done.
...
0
votes
1
answer
49
views
Does grep and friends have a way to match strings as if shell file name globbing in stead of regex
Effectively I'm trying to search a text file containing "file names" and want to match as if shell file globbing were in effect.
Shell file globbing is much simpler than regular expressions, ...
2
votes
1
answer
191
views
Grep only until certain symbol
I try to grep some string and want grep to stop at a '+' symbol. The searched string could be "foo" or "foo+bar". Grep treats all findings no matter what comes after foo and the -w ...
2
votes
1
answer
161
views
Why "mount | grep sdb" displays no output, when "sdb" drive is a [swap] partition?
I'm learning about lsblk and mount commands in Ubuntu.
I'm using Linode vps server, 2CPU, 4GB ram with 1 additional block storage volume attached.
I have 2 questions related with this subject.
At ...
2
votes
1
answer
44
views
How to search output of help message of program (using e.g. grep)
I have a directory with executables and I want to search for a word in the output of the help messages of these executables, i.e. the text that is printed in the console after using the command ./...
9
votes
2
answers
504
views
Grep ignore array of patterns
Since I learned some bash syntax, I have being very enthusiastic about its use in daily life. A famous command is grep. In case one with to grep something but ignore several files, the commands below ...
0
votes
1
answer
38
views
How to list disk usage by directory, excluding certain output
I am trying to get a sense of disk usage and I want to exclude the ones I cannot access like this - any suggestions?
sudo du -h / --max-depth=1 | grep -v "cannot access"
Thanks.
2
votes
1
answer
315
views
How to log URL to a file only if it’s HTTP status code is 200?
I want to make a script so I can check if I can connect to several URL.
For example I do curl -i -L --silent URL | grep "HTTP/2 200" >> *.txt
I want to combine it with an if statement ...
1
vote
1
answer
181
views
chkrootkit says "grep --color=auto INFECTED," what should I do?
I just installed and ran chkrootkit for the first time and when I ran sudo chkrootkit | grep INFECTED, it returned ![user] 21342 pts/0 grep --color=auto INFECTED
I'm a complete novice at this and ...
0
votes
0
answers
216
views
How to replace URLs from html to a file using grep, sed or any common tools?
I'm trying to replace URLs of my conf file from a HTML file because sometimes the URLs get updated/changed. I need a simple script that can fetch the HTML & update/replace the URLs in my conf file....
0
votes
1
answer
264
views
How to exclude words using grep?
Instead of me chaining these like 10 times
cat /var/log/nginx/access.log | grep -v download | grep -v danger | grep -v "/visitor/return" | grep -v welcome | grep -v "GET / HTTP" | ...
0
votes
1
answer
112
views
Uniq --count doesn't work properly
I'm trying to solve a problem with counting IPs using uniq -c.
My file after using file looks like this :
69.246.75.77
7.44.104.171
195.82.180.9
195.82.180.9
61.115.160.23
56.240.142.58
195.82.180.9
...
0
votes
0
answers
159
views
IPv6 Tunnel For Ubuntu
Hi Dear Friend I Want Run IPv6 tunnel Between 2 Ubuntu and Forward Traffic ipv4 I test Gre tunnel
Error: an IP address is expected rather than
Gre in Ubuntu Donnot support ipv6 For local And Dst ...
0
votes
0
answers
73
views
grep and pipe combination to filter standat input
Why this is working
gdbus monitor -y -d org.freedesktop.login1 | grep org
Filtering output lines containing "org"
This is working
gdbus monitor -y -d org.freedesktop.login1 | (while read ...
1
vote
1
answer
120
views
Grep doesn't return any value in the search
I am looking for a specific value while searching a text file, but with grep I am unable to pull that value. with -head 50, I can see the first 50 lines.
with cat and filename, I see the output as ...
0
votes
2
answers
103
views
Mean of wc -l in grep command
Is the wc -l showing how many times the search string is found in the binary file?
-l, --lines
print the newline counts (I think a newline is an empty line?)
grep --binary-files=text '...
1
vote
1
answer
93
views
How to grep certain attribute from openldap?
I am using openldap and usually I will use command ldapsearch uid=<ldap> + to check certain attribute and by running such command, it will produce full output for example :
SASL/EXTERNAL ...
2
votes
1
answer
458
views
Grep output from application, show to screen and write to file?
I run an application and pipe the output to grep. This works. However, I wish to show the output on both screen and write to file.
So I am piping the grep result to tee:
./app | grep something | tee ...
0
votes
0
answers
174
views
How to search full website for a specific string?
So, my ISP has a media server which can only accessed by it's users. That server has a lot of directories and no search functionalities to search for certain files.
I tried using google dork ...
0
votes
2
answers
704
views
grep fails to find text in docx file
I cannot find the reason why grep cannot find the file with the word 'coomunities'. I used
grep -ril --include=GLOB "coomunities" .
Note: communities is on purpose mispelled.
The file is a ...
0
votes
1
answer
236
views
grep command to get file list with concatenated custom text
I am trying to list of files' names with custom text(my another command) with it. I am using below command:
grep -rl --include=*.php --include=*.html --include=*.js 'ajax.googleapis.com/ajax/libs/...
0
votes
2
answers
86
views
Grep file for one target (+ next 3 lines) OR another target (just that line)
I want to search a file for two target strings. For the first target I wish to return that line and the 3 lines following it. For the second target string I want to return just the line containing the ...
1
vote
1
answer
246
views
Using ssh how to remotely check to see if python3 or any other given package is installed on my server?
I have an Ubuntu server with ssh key already set up on it. Without having to log in, and from a bash script that will run on my local machine I want to check if a given package is already installed on ...
-1
votes
1
answer
161
views
Escaping wildcard for grep in bash scripts
How does one do globs for grep? Should one escape the wildcard (*) inside bash scripts? Or only escape it when writing on the command line? How can I detect the enclosing brackets pattern {...} in ...
0
votes
2
answers
160
views
Any limitation of grep command?
Is there any limitation of grep command?
I have a 548KB syslog file, I use the grep command to filter it.
I got 2583 lines output, the last line show the end of time May 28 05:37:40; But actually, ...
0
votes
1
answer
184
views
Colouring grep pattern match with a preferred colour
I am using the following pattern matching to colour in a preferred colour using tput.
| sed -r $"s/^==> .* <==$/$(tput setaf 46)&$(tput sgr0)/"
I wonder if I can do a similar ...
0
votes
1
answer
178
views
I need help trying to make a functional Zenity list
Here is what I have so far
#!/bin/bash
zenity --list --title "Packages" --list --text "select packages you want to install" --checklist --column "id" --column "...
0
votes
0
answers
690
views
Searching text from a list in another file
Is there a grep-like program for Ubuntu that can search a text file, or batch of text files in a folder, for any occurances of words in another text file or a list like a csv file or an ods file or ...
0
votes
0
answers
227
views
bash script for grep with context
Am writing a bash script that uses grep to search phrases and prints them on terminal. I want the user to have the possibility of using the context options of grep (-C, -A, -B). I made an indexed ...
2
votes
2
answers
1k
views
Using grep to find tag and get arbitrary string after it
So I have this pattern, the whole thing is one line
<img itemprop="image" class="hovered__image jsOpenGallery lazyload" data-src="//static.yellowpages.ca/ypca/ypui-6.65.0....
1
vote
1
answer
72
views
How to find searchable PDFs
I have a folder with many PDFs. Some are no doubt searchable. Can I search for and identify only those which are searchable?
Adobe gives an error message if a PDF is an image, asking if you want to ...
6
votes
2
answers
785
views
How do I grep for arabic characters with diacritical marks?
I have large TXT files in arabic Tashkil and I'm trying to find lines that contain specific pattern mashkula with َ ً ُ ٌ ّ ْ ٍ , I've tried the following grep syntax:
cat file.txt | grep "...
0
votes
2
answers
346
views
bash: do not show the part of the line that is in the search terms of the grep command
For example I have a directory:
/A/B/C/D/E/F/G.txt
Not knowing a priori /E/F/G.txt, I need to isolate that part. For ease of example:
echo '/A/B/C/D/E/F/G.txt' | grep -o '/A/B/C/D'
Shows:
/A/B/C/D
...
0
votes
1
answer
194
views
Print the path using grep (or alternative commands)
In bash file I have:
Path="/home/name/logs/*.log", and I need to print just /home/name/logs.
How can I use grep (or other commands) to do this?
1
vote
1
answer
102
views
VLC how to play all files that contain specific word
I would like to play all files in all subdirectories that contain specific term.
I tried it using:
find . -type f | grep Song | vlc
I think I might be misunderstanding how | works, because it doesn't ...