Linux grep and find command

Grep

find all log files

 find . | grep .log$
ls /var/log | grep -c .log
11
grep -e Started* /var/log/boot.log
grep -e Started* /var/log/boot.log -n
grep -e Started* /var/log -r

Find

find file by name(pattern)

find . -name boot.log
./var/log/boot.log
find . -name *.log
./var/log/tuned/tuned.log
./var/log/audit/audit.log
find /var/log -iname *Network.*log
/var/log/vmware-network.2.log
/var/log/vmware-network.1.log
/var/log/vmware-network.log
find /var/log -type d
/var/log
/var/log/tuned
/var/log/audit
..
find /var/log -name *network.log -delete
find /var/log -iname *network*1.log -exec rm -i {} \;
find /var/log -mtime -1
find /var/log -ctime -1
find /var/log -type f -mmin -30
/var/log/audit/audit.log
/var/log/messages
/var/log/vmware-vmsvc-root.log
/var/log/cron
find /var/log -type f -mmin -30 | xargs ls -l
-rw — — — -. 1 root root 151063 Apr 2 03:06 /var/log/audit/audit.log
-rw — — — -. 1 root root 1614 Apr 2 03:01 /var/log/cron
-rw — — — -. 1 root root 278547 Apr 2 03:05 /var/log/messages
-rw — — — -. 1 root root 67238 Apr 2 03:20 /var/log/vmware-vmsvc-root.log
find . -type f -size +10M -size -50M | xargs ls -l
find /var/log -user root | xargs ls -l
find /var/log -group root | xargs ls -l
find /var/log -type d -perm 755 | xargs ls -l
find . -empty
find empty files
find . -type f -empty
find /var/log -type f -iname *log | xargs grep boot

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
LORY

LORY

A Senior Software Developer/Body builder . to help others enjoy coding and stay healthy