Sunday, October 04, 2015

Search for files on Linux, Freebsd by type, content, size and date

The Linux offers a number of tools that can be used on the command line. I have found the following useful

Find files with certain text
grep -r "Text to find" PATH
e.g. grep -r "bad text" /home/user/www/
If you just want the file names
grep -r "Text to find" PATH | cut -d: -f1
e.g.  grep -r "bad text" /home/user/www/ | cut -d: -f1
If you want to find certain files
find . -type f -name "101.php"
for a case insensitive search
find . -type f -iname "101.php"
Wildcards work too
find . -type f -name "*.php"
for a case insensitive search
find . -type f -iname "*.php"
Suppose you want to find all the files modified between a certain dates. This works

touch -t yyyymmddhhmm tempfile1
touch -t yyyymmddhhmm tempfile2
find /www/ -type f -newer tempfile1 -not -newer tempfile2
e.g.
touch -t 201510010000 /tmp/startfile
touch -t 201510010000 /tmp/endfile
find /www/ -type f -newer /tmp/startfile -not -newer /tmp/endfile
Find specific files, e.g. php files, between certain dates

touch -t yyyymmddhhmm tempfile1
touch -t yyyymmddhhmm tempfile2
find /www/ -type f -name "*.php" -newer tempfile1 -not -newer tempfile2
e.g.
touch -t 201510010000 /tmp/startfile
touch -t 201510010000 /tmp/endfile
find /www/ -type f -name "*.php"  -newer /tmp/startfile -not -newer /tmp/endfile
 References

Audio Noise Removal

Many times in record clips we end up with unwanted background noise. Recently faced with the situation, I  needed to clean up some audio and...