My goal is to write a script that finds all the files with a certain extension and then make symbolic links to those files. The way I've tried to go about this in a prototype is by:
Code:
files=$(find $HOME -type f -name "*.test")
for file in $files
do
echo $file
ln -s $file /tmp/test/$file
done
There's a couple problems with this method though.
1. Let's say $file's path is "/home/user/dir/f.test" . This gets expanded into [code]ln -s /home/user/dir/f.test /tmp/test/user/dir/f.test giving a directory not found error. That also isn't what I want it to do. I want it do ln -s /home/usr/dir/f.test /tmp/test/f.test . I've tried using cut to get the field I want, but as far as I know there isn't a way to get the last field unless you know how many there are.
2. If I give find the $HOME directory then find will search the Trash which is something I don't want it to do. I've kludged around this problem by chmoding the Trash folder to 000.
So I'm looking for some way to exclude specific sub-directories from find, a way to parse the absolute filepaths it provides, or a different, better solution.
Thanks for any tips!