Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [grep]

grep is a command-line utility that is used for searching text.

1
vote
2answers
28 views

How to take value as value without considering it as string when we do cat and grep

I have created the utility that need to be run in all the system without any error by creating the required environment. When ever I run the following command it will take the path value from a config ...
0
votes
1answer
28 views

Terminal only outputs last few lines and everything before is deleted

I am using grep to find strings in multiple files. It outputs a lot of text which is what I need, but then terminal just deletes all the output while grep continues working and so I can see only last ...
-1
votes
2answers
28 views

grep and sed only the numbers from a text file's line

I'd like to extract only a number from a text file. It is like: corner_lat: 49.0425000 decimal degrees I am using the following expression : grep corner_lat EQA.dem_par | sed "s,[^0-9]*,," ...
-2
votes
0answers
57 views

What is the equivalent grep command of CentOs in Ubuntu 18.4? [on hold]

I have following grep command number_of_inputs=$(($(grep -Pzo '^.inputs(.*?\\\n)*.*?$' output.blif | tr -d '\\' | wc -w) - 1)) that was written for CentOS to search for the number of inputs in the ...
0
votes
2answers
92 views

Regex “.*?” giving same output as “.*”

This the file I am using: Shane is a little to play ball small silly When I use egrep 's.*l' new I am getting the output as Shane is a little to play ball small silly When I use egrep 's.*?l' ...
0
votes
1answer
46 views

Bash: Trouble passing arguments to grep from script

Trying to learn a little of bash scripting and I end up using the 'grep --color -r -n -i SEARCH .' command a lot, so I figured I'd script that. Problem is that I can't seem to pass my search term to ...
9
votes
2answers
526 views

Using AWK to get second column

I can not seem to get the awk command to get the second column of data. Bash Code: filter_data=$(awk "{if(/$filter:/) print $2}" < scanresults_temp.txt) printf "$filter_data \n" The $filter ...
3
votes
1answer
88 views

SHASUMS AND grep in verifying Ubuntu download

I'm trying to better understand the use of "SHA256SUMS" and "grep." The Ubuntu verify and authenticate tutorial uses the following term: "sha256sum -c SHA256SUMS 2>&1 | grep OK" to verify the ...
6
votes
1answer
236 views

Why doesn't grep -r also look in subdirectories when I search with a glob? [duplicate]

Grep with -r was not working for me. I then made a test situation. The directory /home/den/backup now contains a file with the word washer in it. I also made a subdirectory within /home/den/backup. ...
0
votes
2answers
24 views

Splitting data based on semi colon and picking up unique IDs

I have file that looks like this: 26. ZINC19693599 27. ZINC19693598 28. AKOS032468089; ZINC575619353; F6561-5795 ... 29. MolPort-039-321-788; ZINC46759513; AKOS030658283 30. MolPort-039-315-229; ...
4
votes
3answers
287 views

Sorting values and grepping the best score (highest number)

I have a file that looks like this: 7 C00000002 score: -41.156 nathvy = 49 nconfs = 2251 8 C00000002 score: -39.520 nathvy = 49 nconfs = 3129 9 C00000004 score: -...
0
votes
4answers
55 views

How to count the characters within quotes?

Example: Known Data: Total population = "150" Question: Using bash how can I find out the number of characters within quotes? and assign that output to a variable?
2
votes
2answers
235 views

How do I use grep to search for lines containing all words in a list with no specific order in a text file? [duplicate]

How can we use grep to get line(s) containing a group of words, while the order of words is not important, although line(s) should contain all words mentioned in search? I have done that with phasing ...
2
votes
3answers
85 views

How to insert a line break between stderr and stdout

This question helped me understand how to combine stderr and stdout: How to redirect stderr to a file with this command: gunzip -vc /opt/minecraft/wonders/logs/20* 2>&1 But how may one ...
0
votes
1answer
33 views

Find all non-NUL bytes in a file

I am zeroing media with simple pv /dev/zero > ... and want to know if after this command there is any other byte on the media. This would allow me to know that media is corrupted. I assume ideal ...
0
votes
2answers
93 views

Ambiguous redirect, grep command

It was an exercise from one Linux textbook: to give an example both input and output redirected. I found an answer in web: grep \$Id < *.c > id_list But this *.c seems to be the problem. ...
1
vote
2answers
66 views

Parsing Text File By Column Pattern

I was wondering if there is an easy way to use awk or any other command to parse a text file such that a file of something like: Step Temp Enthalpy 0 0 -368 100 1 -369 200 2 -372 300 6 ...
1
vote
1answer
29 views

Is grep 2.25 the most recent version available for ubuntu 16.04? [duplicate]

As I was learning (teaching myself) to use grep, I ran into a problem, some examples I was testing didn't work as I expected. I decided to try to figure out the problem on my own. First I would check ...
0
votes
1answer
41 views

Need help on an egrep regex

I am trying to create an egrep command to grep the number of lines containing a specific text from a text-file but seem to have an error somewhere. The text-file contains several thousand lines and ...
0
votes
1answer
155 views

grep to search word in a file and result given that word with ZIPfile name that contain that word [duplicate]

Here is what I am doing: I want to find which zip files includes this number with number itself for example i want the result be like this : 7505857289 AIRCDR where the number is my search result ...
0
votes
0answers
25 views

Script which checks for a running process [duplicate]

I would like to implement a .sh script which checks whether a process is running or not. I place a cron job which runs the .sh script every ten minutes. If the process is not running, I would like to ...
0
votes
1answer
150 views

How to use a script to end a cron job?

I currently have a cron job that I need to stop on shutdown. During power off, I currently run a "shutdown" script, but I am unsure of how to take the PID number I get from ps -ef | grep cron and put ...
0
votes
1answer
141 views

dpkg --get-selections | grep hold not working in 16.04

I am getting this error The following packages have unmet dependencies: phpmyadmin : Depends: ttf-dejavu-core but it is not going to be installed Recommends: mysql-client E: Unable to ...
0
votes
1answer
72 views

What is uname-r | grep fc?

I was reading a .sh file and find a line written as if[ "`uname -r | grep fc`" == " " ]; then But I don't find the meaning of fc and the whole expression. I am using Ubuntu 16.04 LTS. Thanks in ...
0
votes
1answer
161 views

“ls | grep zip” vs. “grep zip $(ls)”

I'm learning about expansion/ command substitution, and while paying around with an example, noticed that these two commands have different results. For example, if I cd into /usr/bin, and run ls | ...
0
votes
2answers
31 views

Ignoring an output with grep

I am currently using grep to locate a string in a file. However, I get a result I do not want. Example output: user@user:~/tmp$ grep "z=" note > tmp.txt | cat tmp.txt z=0.016728 S_1.4 GHz= ...
20
votes
2answers
1k views

Modifying the color of grep

When I grep something, the result is always in red. I know that the command grep --color prints the result in color, which by default is red. Can I change the color?
0
votes
1answer
47 views

how can i grep something out of a list

How can i grep, sed, cut, xargs or awk the output of lspci I'm looking to get the latency time, the name of the device and the number on the left, whatever that is I've tried lspci -vv | egrep ...
0
votes
0answers
31 views

How can i target punctuation marks when dealing with text

I want to print a file like this after i saved it as file.fw nvram set wl0.2_key4=; nvram set wl0_wds1_ospf=; nvram set wl0_stbc_tx=auto; nvram set wl0_ap_isolate=0; nvram set wl0_ampdu=auto; nvram ...
1
vote
0answers
53 views

Searching a word throughout the system without knowing its address [duplicate]

I want to search a word in my computer and i don't know where it is. For example, i wanna search the word Ubuntu in all texts(word, txt,...) on my pc. In present directory, i use cat * | grep Ubuntu ...
2
votes
1answer
25 views

Running a mv command on large amount of data caused disappearance of other folders [closed]

I messed up by running a mv command on the entire contents of an old external drive to my Desktop without making a destination folder first. I ran sudo mv /my/external/path/* /home/myself/Desktop/ ...
1
vote
1answer
345 views

ack-grep: command not found after upgrade to Ubuntu 18.04

sudo apt-get install ack-grep gives ack-grep is already the newest version (2.22-1) but ack-grep gives ack-grep: command not found It was working fine in Ubuntu 16.04, before upgrading to 18.04
0
votes
1answer
48 views

copying files resulting from using grep into a new folder

I have a question concerning the concatenation of two processes in the terminal. I have a folder with over 50.000 files. I used grep to look for those files containing a specific term: grep -inrl "...
5
votes
1answer
358 views

Bash: info with systemctl

With systemctl status name.service | grep Active I get this info: Active: active (running) since Mon 2018-05-14 21:44:09 CEST; 5s ago How can I get the same info but without: "Active: "?
11
votes
5answers
2k views

grep to return Nth and Mth lines before and after the match

I know that with grep I can use the fields -A and -B to pull previous and next lines from a match. However they pull in all lines between the match based on however many lines are specified. grep -...
2
votes
1answer
47 views

find grep exec, result

If I run the following command find ./dir -type f -newermt 2017-04-01 ! -newermt 2018-06-30 -printf "%TY/%Tm/%Td %TH:%TM:%.2TS %p\n" -exec grep -E -l "pattern" {} \; | sort -n; will return this: ...
1
vote
0answers
22 views

Recently installed ubuntu 18.04 erasing windows, and show no wifi adapter found [duplicate]

on typing : lspci -vnn | grep Network it showed : 03:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. Device [10ec:d723] I am using HP Notebook - 15q-by004ax Wifi was working on ...
3
votes
1answer
84 views

how to scan all clients if they contain files with a specific line of text

So I am going to ask for something major here and that is if I can scan from one device all other connected devices to see if they have a specific line of text in any of their files. It is a bit ...
1
vote
1answer
348 views

How to find a line starting with 'a' and ending with 'c' using grep?

I have a file named newfile. The contents of this file are: abc xyz abc Now I want to find lines which start with a and end with c. I enter the following command but the results are not the same as ...
1
vote
1answer
54 views

killing the bash interpreter

Im trying to kill /bin/bash but when I do ps aux | grep "/bin/bash" and I kill the pid associated with it, it gaves me an error. Any help is greatly appreciated. Also can you tell me what's the ...
4
votes
1answer
327 views

What does the asterisk (*) do in grep -nri “searchString” *?

Normally while searching using grep, the command I was using was this: grep -nri "String" whereas most of my colleagues do this: grep -nri "String" * What does the latter do (the * part)?
0
votes
1answer
38 views

Grep - show the whole line when search found with search term of special characters

I am trying to search in the root folder that contains a bunch of Joomla sites inside subfolders to have a sneak preview of the public $db variable of the configuration.php file of each site. Note ...
2
votes
4answers
936 views

How to grep for two patterns in multiple files

I have multiple files in multiple directories, and I need a grep command which can return the output only when both the patterns are present in the file. The patterns are like AccessToken and ...
6
votes
2answers
1k views

Limit grep output to short lines

I often use grep to find files having a certain entry like this: grep -R 'MyClassName' The good thing is that it returns the files, their contents and marks the found string in red. The bad thing is ...
1
vote
3answers
302 views

Grep to return entire file content

I want to search recursively for a certain word, say MyWord, but I want to print the entire contents of all files that contain MyWord. How do I do this? It turns out that I particularly care about ...
0
votes
1answer
611 views

How do I grep for words with an exact number of occurrences of a letter?

I'm trying to write a script that searches a dictionary for words that contain exactly two occurrences of each letter. I just don't the syntax to grep for exactly two occurrences of a letter.
2
votes
0answers
35 views

searching for “created_at”: followed in the next line by “retweeted”: in lots of json files for a specific range

I have a large amount of json files and previously I was told to use the following line to search if a tweet is created at a specific time range in a date: grep -wirnEzc '},.*created_at":\s"Wed Oct ...
0
votes
4answers
1k views

Find multiple word-patterns in files

I have around 50000 files (.txt) and more items in filesdir folder.The values: 'fax', 'phone', 'address' are presented in different configurations in these files. I need to find all files which ...
0
votes
0answers
31 views

Find phrase in list of files [duplicate]

Trying to find all files in current directory and sub directories that contains phrase hello. According to my understanding this should work: find -follow | cat | grep "hello" Firs of all I'm trying ...
4
votes
6answers
606 views

Extract one element from lines of a text file

Command grep will print a line when the line contains a string that matches an expression, which is not handy to search for specifed content. For instance, I have vocabulary files with formatting **...