Cacomania: tag

Cacomania

Search all config files for a specific term

Guido Krömer - 1492 days ago - Tags: , ,

A common problem, which of all ini file contains the part loading module XYZ?

The find command below searches all ini files in the /etc folder for the term "mysqli".

$ find /etc -name "*.ini" -printf "echo \"FILE: %f\"\ngrep \"mysqli\" %h/%f\n" | bash

Comment

Monitor file copy progress with find and watch

Guido Krömer - 1535 days ago - Tags: ,

Currently copying a large amount of files and wants to see if the job is still running?

watch

find lists all files in the folder and his sub-folders, wc -l count the lines from stdout and watch executes this every two seconds.

$ watch "find ./ -type f | wc -l"

Comment

Merging files together

Guido Krömer - 1722 days ago - Tags: ,

Having a website CSS or JS separated into different files and sorted in sub folders is great for development, but ends up in many requests during live operation. Instead of using a “complex” script which merges those files together this one liner can do the job, too.

# find /path/to/css/* -type f -name *.css | xargs cat > /path/to/css/screen.css

Comment [1]

Auto cleaning up your download folder with find

Guido Krömer - 1743 days ago - Tags: ,

Is your download folder messy, too? Why not let find tidy it up periodically?

# find ~/Downloads/* -ctime +7 -exec rm -rf {} \;

The command above let find search for files and folder which are older than 7 days and deletes them. But be carefully files in a folder will be deleted even if the file age is newer than 7 days if the folder is older than 7 days!

0 * * * * find ~/Downloads/* -ctime +7 -exec rm -rf {} \; > ~/Downloads/deleted.files

Running this as a cronjob will do the work once a hour, or how often you wants.

Comment