The command "find" is one of my favorites -
Search for files in /search/path/ which are older than 5 days.
(if you want to search for directories, then use: -type d )
find /search/path/ -type f -mtime +5 -print
find /search/path/ -type d -mtime +5 -print
If you want to do something with those files after you've found them, use: -exec <somecmd> '{}' \;
Example, delete files older than 50 days in the /search/path directory
find /search/path/ -type f -mtime +50 -exec rm '{}' \;
If only there is a 'find' equivalent in the real world ... now, where did I put my keys?
I get more use out of grep either directly or in a pipe. The color option has really helped me identify my find and I am also a fan of the -A and -B options to show context. These display the matching line and the specfied number of lines After or Before.
$ grep -i '^<directory' -A5 /etc/httpd/conf/httpd.conf
I also use a lot of cd - to flip back and forth between directories and CTR-r to search history.
I agree with you. I love grep, especially when filtering through a large amount of data using grep piped to grep with regular expressions. The -v option is great for eliminating lines that contain strings that are NOT included in the lines you are looking for.
grep '^Apr 1 15:5[34].*ERROR' /var/log/messages | grep -v '[az0-9]\{32\}'
Hah, easye one: man
love man and how you can look up help anywhere with or without internet , Also ps -ef has been by far my favorite followed by a kill -9
@fuadar wrote:ps -ef has been by far my favorite followed by a kill -9
pgrep and pkill are going to rock your world.
I recently discovered kill -15.
Don't know about favorite, byt here's my most used commands from my bash history: ssh, nmcli, ls, sudo, cd, ansible, rm, rsync, cat, man, less, mv, curl, dnf, echo, scp, python, top, perl
Apparently my own favorite is dnf. Lol.
Mine is not a command per se (at least not in the normal sense) but is the capabilities enabled by the pipe character. I've lost count how many ways I've been able to construct complex one-liners using the pipe character, to enormously beneficial effect.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.