File manipulation using FIND

These examples are Ubuntu 12.04 and Apache2

FIND

find a file by name #

sudo find ~/ -name 'banner3.jpg' 2>/dev/null

find and copy # combined to make a script to double filter

sudo find /media/backup01/* -name '*.txt' -exec cp {} ~/dump \;

+ increases speed

sudo find . -name '*.py' -exec grep --color 'xrange' {} +

FIND and EXEC (execute another command)

sudo find /var/www/www.example.com/media/ -type f -name "*.jpg" -exec chmod 775 {} \;

FIND and DELETE lines matching pattern in log files

sudo find *.log -type f -exec sed -i -e '/88\.66\.4\.92/d' {} \;

FIND and edit file (not create a new file)

sudo find . -type f -exec sed -i -e 's/pattern/replace/g' {} \;

find all files in /directoryname and copy to another directory /home/username/directory

sudo find /directoryname -iname "*file*.txt" -exec cp {} /home/username/directory \;

useful for upgrading software – list all directories in /var/www THEN copy all files in directory-name to each

sudo find /var/www -maxdepth 1 -type d | cp -Rf ~/directory-name/* '*'

FIND directories 1 level deep and execute a script on them

sudo find -maxdepth 1 -type d | ~/close-wp.sh '*'

FIND directories 1 level deep and move them to another directory

sudo find -maxdepth 1 -type d | mv '*' /home/username/directory-name

FIND and DELETE directories

sudo find /media/ -type d -name 'directory-name' -exec rm -r {} \;

FIND and DELETE images larger than x

sudo find /var/www/www.example.com/wp-content/uploads/ -type f -size +100k -exec rm -r {} \;

FIND and DELETE files older than 5 days | -mtime = days

sudo find /path/to/files* -mtime +5 -exec rm {} \;

More…AWK GREP SED VI and FIND Cheatsheet

If you found this page useful, please Google+ or link back even better Thanks!


Proof that a well written article will not, by virtue of content alone, result in a #1 position in search rank. I was writing an article about “seo for franchise organizations“. So I searched for other ideas and for competition in the space. My jaw dropped by this post in #1 3 On-Page SEO Mistakes and Tips for Franchisees

I hate to link to it, but the point could not be made without it. I know Hubspot. But this article is way below acceptable compared to the other excellent articles in positions 2 through 7. I wonder how that is accomplished!

Unix-Linux Does Not Require Disk Defrag

February 18, 2013

I’m a convert to Linux in the last several years. I don’t remember when it happened exactly, but I vividly remember the first time I (tried to) used Microsoft Office 2007, I was sure I was on the right path. Recently some friends have asked me why they should make the migration to Linux. I [...]

Read the full article →

Ubuntu Halts on Boot – Solved – Disable IPv6

February 13, 2013

Ubuntu Desktop 12.04 Hangs During Boot sudo gedit /etc/sysctl.conf Add: # IPv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 Restart: sudo sysctl -p

Read the full article →

Eliminate error “127.0.0.1 Directory index forbidden by Options directive” in log files (and other needless noise)

December 26, 2012

Ubuntu Apache Error : client 127.0.0.1 Directory index forbidden by Options directive This error and many others clog your log files with noise which can be easily eliminated without compromising security. The reason I get this error is because I have set .htaccess in the server root directory to Options -Index for security reasons. I [...]

Read the full article →

Beware Giving Vendors Your WMT Logins

December 4, 2012

This qualifies as one of the “Commandments” for clients. Do not give a 3rd party vendor your Webmaster Logins What are Webmaster Logins? What is WMT? David Naylor was of course one of the first to write about this trouble with WMT. To the average business owner, it is not obvious what all the trouble [...]

Read the full article →

The Weak Link in Ubuntu 12.04 Desktop

November 9, 2012

I’ve tried to love Unity. I keep trying every time I install Ubuntu since Unity was introduced as the GUI of choice. I’ve read a lot about UI design over the years, (Doug Engelbart to John Sculley’s Personal Digital Assistant) so I don’t think I’m a curmudeon about it. But I just can’t be productive [...]

Read the full article →

Edit “Other Applications List” in Unity Ubuntu 12.04 Desktop

November 7, 2012

When installing Padre IDE on Ubuntu Desktop, I found Ubuntu (12.04) does not recognize it as an already installed program. So when trying to open a Perl file for editing using right-click, its a dead end – Padre was nowhere to be found. I wasted an hour looking for the answer; found it here > [...]

Read the full article →

Search Statistic 2012

October 19, 2012

Natural Search results, #1 spot gets 53% of clicks In Paid Search results, #1 spot gets 85% of clicks The Compete Report can be downloaded here. Keep in Touch Find me on Google+  

Read the full article →

Does Paid Search Actually Work or is it just an Advertising Racket?

October 18, 2012

Its not uncommon to find new-comers to the online advertising business have a natural skepticism about paid search advertising. Lets look at an actual recent campaign and the results. Here is what a client said after initiating an aggressive Google Adwords campaign. Keep in Touch Find me on Google+  

Read the full article →