Command Line Reminders

21/11/11

Permalink 09:52:29 am, by Greg, 181 words, 464 views   English (CA)
Categories: Announcements; Mins. worked: 0

Command Line Reminders

Searching with find
Example: find all jpg images from this location and copy them to another location - and don't change permissions or timestamps.
find . -iname '*.jpg' -exec cp -p {} ~/Desktop/test/ \;
and
find . -iname '*.php' -exec chmod 700 {} \;
which will find all php files from here and change permissions on them to conform to the whole suPHP thing (only user-readable php files etc.)

Another one:
find . -type l -name '*.png' -exec mv {} ~/Desktop/crap/ \;
will find all of the symlink-ed png files and move them somewhere

One that matches all text files on the entire system (that is, searching recursively from /) over 10KB, owned by paul, that are not readable by other users, and then use chmod to enable reading, like this:

find / -name "*.txt" -size +10k -user paul -not -perm +o=r -exec chmod o+r {} \;

Find all recently modified files:
find . -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort

NOTE: When typing -exec parameters, be sure to include a space before \;. Otherwise, you might see an error such as missing argument to ´-exec'.


Pingbacks:

No Pingbacks for this post yet...

Maintenance

This blog is the location for all work involving software and hardware maintenance, updates, installs, etc., both routine and urgent, in the server room, the labs and the R&D rooms.

Reports

Categories

April 2014
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      

XML Feeds