Pages

lundi 10 mai 2010

Linux commands

1) How to copy a directory with all files and subdirectories?
src=/home/$USER # source
dst=/tmp/backup # destination
cd "$src"
find . -print | cpio -pdmv "$dst"

2) how to use find ?
find is a powerful command in linux. Here are some examples.
find . -name '*.jpg' ------------find all file names ending with jpg
find . -mtime +30 --------------find all the files older than 30 days old
find . -mtime -30 ---------------find all the files modified 30 days ago
find . -type f -mtime -30 -exec rm -f {} ---find all the files modified 30 days ago and delete them

Aucun commentaire:

Enregistrer un commentaire