Questions tagged [grep]
grep is a command-line utility that is used for searching text.
681
questions
0
votes
1
answer
31
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
31
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
54
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
125
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
45
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
348
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
38
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
22
views
How to grep part of a path
in bash file I have:
Path="/home/name/logs/*.log"
I need to print just "/home/name/logs"
How can I use grep (or other commands) to do this?
Thanks
1
vote
1
answer
42
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 ...
1
vote
1
answer
23
views
Grep Apache version from shell
with apache2 -v I get the following result:
Server version: Apache/2.4.48 (Ubuntu)
Server built: 2022-01-05T14:29:15
How can I get just "2.4.48" using grep?
Thanks
1
vote
1
answer
57
views
How to automatically open a file that has a dynamic filename
I'm trying to make an automation process, my workflow generates a file automatically, this file is named based on a timestamp and a public key.
Example of the file name : UTC--2022-03-07T10-53-08....
0
votes
0
answers
22
views
Console File Viewer which shows byte position numbers
I have a large data-file with record length 800 bytes. It is to big to open it in gui-texteditors, but less and grep is working fine.
But I need to see fast which number is in the records on position ...
0
votes
2
answers
26
views
how do I filter using grep with logins ending with a specified number
grep
how can I find all the user logins that end with 88 and 89 ?
I can get logins ending with a number if I do
grep "[0-9]" filename
0
votes
0
answers
66
views
Compare two lists, file1 and file2, get the IDs in file2 present in the usernames in file1
Please I need help...
I have two lists, file1 and file2. The list file1 has only usernames, while file2 has the same usernames but with additional columns (username|private yes or no|id).
Basically I ...
0
votes
0
answers
160
views
How do I show all ipv4 and ipv6 addresses by using grep
I'm trying to grep inet addr and inet 6 addr from ifconfig. I can grep inet addr or inet6 addr alone only.
How can I show both IPV4 and IPV6 addresses in one command?
-4
votes
1
answer
61
views
Can I make my own custom grep search tool?
I was trying to find a particular device on my machine. So I typed in lspci. This gave me a large list of items. Too large to constantly look through to see if my device is still attached or not. So I ...
0
votes
1
answer
122
views
grep base on specific date
I have a file somewhere on my linux hard drive which I know was created in November, 2007. I have tried find and grep . Nov ?? 2007 in MANY combinations with no success. What am I missing?
-1
votes
1
answer
74
views
how to use grep -f and -v together
I have 2 files and I extracted information from file 2 based on file 1 by using grep -f file1 file2.
Now if I want to use the output file to check if the columns based on file 1 are not there how can ...
-4
votes
1
answer
49
views
find all files and folders which have specific owner/group with grep
In home/oracle I have many files and folders.
I need 2 different codes to:
find (show) all files and folders belongs to user "Jim" from group "app"
Change user owner of all files ...
0
votes
0
answers
38
views
Find specific numbers of capitalized words next to each other
Let's say I have a .txt file:
Aaa
Aaa Bbb
Aaa Bbb Ccc
I want to find the row that has one capitalized word, two capitalized words, and three capitalized words. So one grep to find Aaa, one grep to ...
0
votes
1
answer
1k
views
Permission Denied Grep
I am completing a school assignment and it's pretty much based off of a murder case. I downloaded the custom files and I am currently searching for keywords within files. The question I am answering ...
6
votes
3
answers
445
views
How to check for a specific string with linebreaks in a file with grep?
I have a string variable in a bash script file as follows:
string="
test1
test2
"
and I want to check whether a file test.txt containts this specific string (including the linebreaks. i....
1
vote
1
answer
287
views
How can I Pipe the output of FFMPEG 2 Levels of Piping in a bash script
I have been trying to pipe 2 levels deep.
I can pipe successfully:
ffmpeg | grep
ffmpeg | sed
I can not pipe
ffmpeg | grep | sed
ffmpeg | sed | grep
I don't understand, does ffmpeg limit to only ...
0
votes
1
answer
498
views
grep command using wildcards [0-9]
grep ".0000000" data > output
I extract the all numeric data ending with .0000000 in the data text file. When I changed this code using wildcard as follows:
grep ".[0-9][0-9][0-9][0-...
3
votes
1
answer
382
views
Where does /usr/bin/grep come from in Ubuntu Focal [duplicate]
When I run which grep on Ubuntu Focal, I get /usr/bin/grep. However, apt-file search /usr/bin/grep does not show a package which delivers it. Moreover, dpkg-query -L grep only shows /bin/grep (among ...
0
votes
2
answers
495
views
how to grep with multiple strings to find
I understand how to use grep in the simple form:
<command that spits out text> | grep "text to find"
I would like to be able to grep multiple different bits of text all at once.
How ...
0
votes
1
answer
77
views
terminal, tail, check 2 logs separated, with grep (or some option)
need check 2 logs in one window. I know there is multitail, but how can I use this with some pipe (grep or some filtering for example)?
Example.
multitail A.log (B.log | grep 193.85.23.66)
Thank you.
1
vote
2
answers
400
views
Grep - How to suppress the "Is a directory" line?
When running
grep 'string' *
I'm getting the following messages:
grep: some-directory: Is a directory
grep: other-directory: Is a directory
How to suppress those messages?
-1
votes
4
answers
162
views
How to cut part of line?
I need to cut line in specific moment, I want to display GPU name, but only name, nothing else.
inxi -Gx | grep Device showing:
Device-2: NVIDIA GK107GLM [Quadro K1100M] vendor: Dell driver: nouveau
...
1
vote
1
answer
74
views
Can't escape a dot using backslash, Why? [duplicate]
So, following are the commands are I ran:
$ ~/Documents: touch ball.txt bool-txt bowl.txt bull.txt
$ ~/Documents: ls . | grep b..l\.txt
ball.txt
bool-txt
bowl.txt
bull.txt
I wasn't expecting bool-txt ...
0
votes
1
answer
584
views
When piping grep after a curl request, regex works very strange
Simple problem but really weird.
When I make a curl request and do ... | grep -Po "^\d+$", it returns nothing eventhough there are 400+ results that should match. See below:
#example snippet ...
0
votes
1
answer
33
views
bash, display only in case output has count of n characters
how can I display content of output which has only count of n characters in second col divided by ,? For example, grep only line which content 4 characters in second col.
Input.
a,123
b,223
c,1234
d,...
0
votes
1
answer
48
views
Grep pattern Matching Doesn't work?
I have a text file like so:
"Id","District Name","Neighborhood Name","Street","Weekday","Month","Day","Hour","Part ...
1
vote
1
answer
93
views
Pattern Matching using Grep
I'm trying to find a specific value for my file heres a quick snippnet of it:
PRODUCT_TYPE_NAME,PRODUCT_CLASS_NAME,PRODUCT_SUB_CLASS_NAME,PRODUCT_MINOR_CLASS_NAME,PRODUCT_COUNTRY_ORIGIN_NAME,...
0
votes
1
answer
91
views
Capture a string from JSON response
I have below Json response for POST method in bash and would like to capture value after sessionId":" and assign it to variable session_ID.
{"changeId":"79911476-53a4-46e1-...
0
votes
1
answer
36
views
Finding a specific text phrase in all system files
Trying to find a specific text phrase in all system files. A terrible way to debug but I have no clue where the mistake is and at this point I do not care whether it takes a day to debug.
I ran
grep -...
-1
votes
2
answers
215
views
How do I grep a exact string from multiple files at the same time? [closed]
I have multiple files(text file) in a folder like below where the 1st file contains some paths as a string and the other with path+file_name.
File1:
# pwd
/root/test
# cat file1.txt
/abc/bce/12345/...
1
vote
3
answers
86
views
How to delete part of a line and keep the rest using Bash?
Suppose that I have an output of lines like this:
First name, Last name, 123456789(9 digits)
GPA
Class
Major
University
How can I write some code to print the first 3 lines and only keep the ID ...
1
vote
1
answer
1k
views
how to use grep and sed on adb logcat
I'm currently using grep in combination with adb logcat (android console api). Now I want to edit every line on the fly using sed in a pipe. However when using sed after grep the output becomes empty. ...
0
votes
1
answer
156
views
how to select the specific string from 'ls' command console output?
I am newbie on linux os. My target is selecting files which have the specific string values in filenames on console mode
This is my sample filename,
filename : apnic-2016-02-01
condition : The first ...
0
votes
1
answer
184
views
Cannot parse dst/src address
I created second ubuntu and then I installed openvpn then I wrote that command:
sudo ss -tupln ׀ grep openvpn
But was written
Error: an inet prefix is expected rather than "׀".
Cannot ...
0
votes
1
answer
774
views
grep: option requires an argument -- 'm' [duplicate]
I'm trying to grep a file in order to find a line containing this text: "-m".
I've created this file to test this issue:
echo "min-value: 2" >> test.txt
echo "original-...
0
votes
0
answers
17
views
Pass string with special character to grep as pattern [duplicate]
Trying to filter command output according pattern -p
docker run --help |grep -F '-p'
But grep treats it as -p as command option:
grep: invalid option -- 'p'
Usage: grep [OPTION]... PATTERNS [FILE]...
...
2
votes
1
answer
990
views
Need to move files found using grep into a folder
As part of a University course, I'm trying to reclusively search for a string in a list of 500 files, and then copy those items found into a new folder.
I can find the files without a problem using
...
2
votes
1
answer
2k
views
grep a string in a json output
I have an api-request that gives the output in the json form (form? layout? body? how do you say that?). See here:
{
"title": "Another Life (2019)",
"...
0
votes
1
answer
30
views
usage of grep command using the file includes the numeric sequences
I have a data file (seq_array) that includes the numeric sequences as follows:
seq 640094400 60 640180770
I have also another file (data_file) that includes the data need to be extracted with respect ...
0
votes
1
answer
841
views
How to grep all the strings which end with '.txt'
I need to find all the strings which end with '.txt' inside text file.
I tried:
grep 'txt$' myFile
But it gives out whole lines, not only the strings which end with '.txt'
2
votes
1
answer
53
views
How to make grep grab the first hit instead of the last
Let's say I have the following string:
hello hi this test is test a test greeting test hello hello
If I do grep -o "hi.*test", I will get:
hi this test is test a test greeting test
It ...
-3
votes
2
answers
736
views
Delete files with same file name
I have a lot of *.srt file in my folder. The thing is I have some same file multiple times with a slightly different name.Like This:
one_piece_001_US.srt
one_piece_SPECIAL_001_US.srt
one_piece_002_US....
0
votes
1
answer
118
views
find files grep result then sort by file datetime modification
I have the following files
**file_01.sh**
abc
bla bla function pause(){
bla
foo function juliet(){
foo
**file_02.sh**
abc
bla bla function pause(){
bla
bla bla jjdjdjd
foo function charlie(...