How to move and/or copy a subset of files from one directory
eg 1 zip files older than 10 days
find . -type f -name '*.trc' -mtime +10 | xargs tar -cvzf bdump_$(date +%Y%m%d).gz.tar --remove-files
|
From time to time I need to move and/or copy a subset of files from one directory to another
#-- delete
find . -type f -ctime -1 | xargs -i rm {}#-- COPY find . -type f -ctime -1 | xargs -I '{}' cp {} /some/other/directory #-- MOVE find . -type f -ctime -1 | xargs -I '{}' mv {} /some/other/directory |
It is very easy to compress a Whole Linux/UNIX directory. It is useful to backup files, email all files, or even to send software you have created to friends. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:
=> Create the archive
=> Compress the archive
You need to use tar command as follows (syntax of tar command):
|
2 comments:
To unzip : tar -xvf filename.tar.gz
Try this if this does not work
find / -iname "*.mp3" -type f | xargs -I '{}' mv {} /mnt/mp3
Post a Comment