Questions tagged [grep]

grep is a command-line tool for searching text patterns in files.

The grep utility searches a pattern (regular expression) in a text file. There are many options to control how matches are performed and how to display matches.

External references

Tutorials

Further reading

See also grep on Unix & Linux Stack Exchange for more detailed reading.

326 questions
0
votes
2 answers

New 64 bit linux system has regular processes (ps, grep etc) taking up way too much VIRT mem

We just moved from a 32-bit machine to a 64-bit machine. We have quickly ran out of memory despite the new boxes have twice as much ram as the old boxes. Running a simple ps command will illustrate the problem. New machine: 132 prod-Charlotte1-node1…
user42980
  • 3
  • 1
0
votes
1 answer

how can I extract a Version number from a website with curl and grep / sed?

I want to get the latets version number from this website: https://www.mailpiler.org/wiki/download so I do a curl to get the content and then just use a pipe to search for the string using grep curl https://www.mailpiler.org/wiki/download | grep…
0
votes
1 answer

Pipe into command stored in bash variable

I enter two command in bash: $export g='grep "something"' $echo "something and another thing" | $g But it doesn't work. I want the second command to be evaluated by bash as : echo "something and another thing" | grep "something" What should I do…
rooni
  • 139
  • 7
0
votes
4 answers

non greedy grep command on ubuntu?

I'm building a script which filters out all our translatables from our template system. the problem i'm facing is the occasion where 2 translatables are on one line. These are 2 example lines from a template file which both hold one or more…
ChrisR
  • 262
  • 3
  • 13
0
votes
0 answers

Using systemd-run To Limit I/O on cPanel for Grep Command

When I run the grep command on Linux on my cPanel-based shared hosting account, I hit an I/O resource limit, it says on the cPanel. I tried to research how to limit resources on a command that I run and came across systemd-run. I don't know if…
ServerChecker
  • 1,518
  • 2
  • 14
  • 35
0
votes
0 answers

Replace a string from the cat output

I need to replace a string with the string which is mentioned in a file abcd.txt in all files in a folder. For eg: I want to replace a string 'apple' with whatever the cat output of this file abcd.txt I used the below command grep -rl 'apple'…
Am3Y
  • 67
  • 6
0
votes
1 answer

How can I highlight lines of a file that begin with abc and DO NOT end with xyz?

I have a daily script that retrieves hardware stats from all of my RHEL servers every night and saves them to a yyyymmdd_daily.log file. I have other scripts that I run against these files to extract specific data (i.e. DriveArrrayStatus,…
0
votes
2 answers

I want to exclude specific words from the results when piping tail into grep

I am using "tail -f /var/log/fail2ban.log -f /var/log/ufw.log | grep -e Ban -e BLOCK -e ALLOW" (without the quotes) and it is working but I want to exclude the results that have the words UDP and ICMP in them. When I try "tail -f…
Greg Azar
  • 1
  • 2
0
votes
1 answer

Regex does not work with grep

Why does this match .*\/.+\/wp-admin.*404 [03/Sep/2021:18:58:29 +0200] "GET /up/wp-admin/install.php HTTP/1.1" 404 6197 regexr.com But in grep it does not? sudo grep -rh ".*\/.+\/wp-admin.*404" /var/log/apache2/ | wc -l 0 I know the line exists in…
0
votes
1 answer

Linux cli pipeline command tail and grep

I am using tail to monitor a log file and using grep to filer the keyword. tail -F somefile.log | grep "keyword" is working tail -F somefile.log | awk '{print $4}' is working but if to put them together is not working, like tail -F somefile.log |…
olo
  • 103
  • 3
0
votes
1 answer

Find all words after specific string

So, here's the thing. I have a file contains like this: LOG=123 HEY=BRO FOO=BAR LOG=124 I need the value of LOG= and an output like this: 123 124 I already tried using this command: echo "$LOG" | egrep -o 'LOG=.*' but it only outputs everything…
Azikun
  • 3
  • 1
0
votes
1 answer

how to avoid grep output empty file

Using grep to print a keyword in a log to the output file grep -i -n "application" /app/log1.log > L1.log Now this gives results if it finds application in the log. But also results empty l1 log file where there are no results. Would like assistance…
0
votes
1 answer

How to grep (Select-String) the output of curl (Invoke-WebRequest) in PowerShell

I'm trying to curl a website and grep it for a specific line in PowerShell. How can I do that? Here's the equivalent of what I'm trying to do, but in BASH user@host:~$ curl -s www.isxkcdshittytoday.com | grep YES title="YES">YES user@host:~$…
Michael Altfield
  • 739
  • 2
  • 8
  • 23
0
votes
0 answers

Summarize first column same field

I have some datas with URL's and used network data. I made a custom file with these data's and i stuck last one step. What i have now: sevroland.api.url.com 488 www.logstach.url.com 42725 localhost 2 goldchipshop43.api.url.com …
TDex
  • 1
0
votes
1 answer

How to change one line of code in a block of code from linux command line?

I have a change I need to make across multiple different sites and may need to make again in the future, so I'd like to put it in a shell script. Essentially I want to find a specific class block in a css file, find one of its attributes and change…
TBridges42
  • 101
  • 2