HomeBanner

Oneliner

One-liner solutions

There are many reasons you may want to use quick one liner solutions to solve your questions while either using the system or administering the system. this section is aiming to provide answers to such actions.

1. How can I locate the biggest files to see what is eating up space ?
2. How can I delete files named nnn.nnn~ via cron ?
3. How can I rename multiple files ? I'd like to change all my pictures from IMG_xxxx.JPG to Disneyland_xxxx.JPG
1.

How can I locate the biggest files to see what is eating up space ?

(as root) This could be a long list, so you might want to redirect the output into a file for perusal...

find / -xdev -type f -size +10000k -mtime -3 -ls | sort -n -k 7,7
	

Note

-xdev only searches the local disk, very useful if you are mounting NFS disks.

Note

You may want to add a '-path '/proc' -path '/dev' -prune' or otherwise keep find out of /dev/ and proc

2.

How can I delete files named nnn.nnn~ via cron ?

Log in as root and execute crontab -e, add a line like this:

0 1  * * *  find / -name '*~' -exec rm {} \;

This command will execute everyday at 1 o'clock in the morning and remove all files that end with a ~. If you want to delete core files, replace *~ with core above.

3.

How can I rename multiple files ? I'd like to change all my pictures from IMG_xxxx.JPG to Disneyland_xxxx.JPG

man mmv assuming that you have mmv installed on your system. Your example would be:

mmv "IMG_*.JPG" "Disneyland_#1.JPG"
	    

You could also use

mmv "IMG_*.*" "Disneyland_#1.#2"
	    

if you had a mix of .JPG and .jpg images that you wanted to rename at once.


Updated: Wed, 04 Feb 2004
Valid CSS!Valid HTML 4.01!