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
1 answer

How to tail server.log and grep multiple text combination?

The server log is too large, I would like to grep the logs which has "/API/login" and "/API/init" from the server log. I'm able to use: tail -f /server.log | grep -i "/API/login" to capture those with "/API/Login" How to add in another condition to…
Tech
  • 3
  • 1
0
votes
2 answers

Grep messages like trash - No such file or directory

my server was hacked, and I am now trying to locate all the "strange" files. I am running: find . -type f -name '*' | xargs grep -l "Mini Shell" This command is helping me a lot to find and delete malicious code. However this is also giving me a…
Pikk
  • 339
  • 1
  • 6
  • 19
0
votes
1 answer

netstat how to exclude localhost from the result when using grep

When I run this command in my terminal: netstat -an | egrep ":80|:443" | sort I got this following output: tcp 0 0 172.104.10.125:48310 172.104.10.125:8081 TIME_WAIT tcp 0 0 172.104.10.125:48316 …
Kalib Zen
  • 137
  • 7
0
votes
1 answer

How to grep lines only with matched words in Linux

I have a little question. I have a list of processes. After this command ps aux | grep postgres I see postgres 1178 0.0 0.2 320064 27060 ? S Apr12 0:05 /usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c…
Piduna
  • 541
  • 4
  • 12
  • 25
0
votes
3 answers

How to remove old kernel on Ubuntu operating system

I am wondering how can I do remove old kernel from Ubuntu operating system. Please refer image screenshot taken. Please advice. Many thanks. list of linux kernel
0
votes
1 answer

check ip is present and update iptables openvpn

I want to check that the ip is present within the ccd folder and push the ip route to the FORWARDING chain in the iptables. Im new to bash scripting and need a little help finishing this script. client file in /etc/openvpn/ccd : ifconfig-push…
Kam-ALIEN
  • 19
  • 5
0
votes
2 answers

Extract string from column with grep

I have a column based .txt file and I want to grep output the Common Name, having a little trouble. V 300223164711Z 01 unknown /C=UK/O=LMG/OU=server/CN=server/name=server/emailAddress=support@kam.org V 300223170002Z 02 unknown…
Kam-ALIEN
  • 19
  • 5
0
votes
1 answer

Script to grep large file

I have a file that has about 63000 row I need to grep though [root@server]# cat missinglinks.txt 69870 1.pdf.Published 125098 2.png.Published 125022 3.pdf.Published 69867 4.png.Published I have a list of 450 numbers that will match some of the…
Andrew Sitterly
  • 300
  • 2
  • 9
0
votes
1 answer

How to print only Users list and Access level from /etc/sudoers?

We have multiple servers and i would like to print users list and access level using bash. I tried below command but could not get exact result what i wanted to: awk '/Allow root/{p=5} p > 0 {print $1; p--}' /etc/sudoers above command just give…
Santosh Garole
  • 453
  • 1
  • 4
  • 11
-1
votes
1 answer

Why grep doesn't work in the /usr/lib/systemd/system directory?

The other day I was on a RHEL7.1 system and I wanted to search for a specific word in the /usr/lib/systemd/system directory where all the systemd unit files are located. I used the grep command as usual. See what happened: # cd…
-1
votes
1 answer

how do i remove local ip from list of ip addresses?

I have a variable that contains list of ips and i will like to remove the ip of the instance where the variable is set Please see below [root@ip-10-10-2-100 ~]# INSTANCE_IP=$(curl -s…
uberrebu
  • 503
  • 6
  • 17
  • 36
-1
votes
2 answers

Find all files which contain pattern in directory of tar files

I have all tar files in a directory. I want to find some files in tar files without extract all tar files. I know how to work with one tar file: tar tvf abc.tar | grep xyz I want to find in all tar files but I don't know how to.
Minh Ha Pham
  • 121
  • 6
-1
votes
1 answer

How can I visualize a file removing every type of comment if a file (including /* */)?

I have this small script to visualize config files without the comment lines: cat $1 | grep -Ev '[:blank]*#|^[:blank]*$' | pygmentize -g but it still shows some comments in some files when they have the /* */. How can I visualize a file, removing…
Nelson Teixeira
  • 225
  • 1
  • 3
  • 15
-1
votes
2 answers

Parse Apache logs for specific verbiage within the last hour

I'm looking to parse my /var/log/httpd folder which contains a lot of Apache log files. I'm looking for specific events within the last hour. I've tried the below, but I didn't have any luck. grep -R "$(date -d -1hour +'%Y-%m-%d %H')"…
Pat
  • 274
  • 3
  • 14
-1
votes
2 answers

how to check null value in grep command using in shell script?

In shell script in centos, i write following 2 lines cmdread="Myprogram" kill -9 `ps ax | grep $cmdread ` But some times when manually myprogram stopped then my shell script give me warning that nothing to kill. So how to check like following if(by…
Mandar Khire
  • 13
  • 1
  • 5
1 2 3
21
22