Hi, hopefully someone can help me. I am writing a simple bash script that will check which files have been modified with the last 24hrs and copy them to an external drive. All the modified files are written to a txt file, for example /home/ben/text.txt. What I am wondering is how I can strip out the file name so I am left with /home/ben. I want to use this method to create the directory structure prior to moving files. Any help would be great thanks.
But another way to approach it is to use a copying program that automatically creates parent directories for files.
Look at the man page for rsync, all of that can be done with the dryrun
option. Then use rsync to do the backup, make life easy for yourself
Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel 188.8.131.52-9-default
up 0:17, 3 users, load average: 0.19, 0.25, 0.29
GPU GeForce 6600 TE/6200 TE - Driver Version: 180.22
Thanks for your quick replies. I hoping to find something using awk or sed I believe. I have looked at rsync and am currently using cp --parents to create the directory structure, however I prefer the way I described mainly so I can know how to do it, and use it in other scripts. There are also going to be some situations where I will need to do it this way in my current scripts.