I am looking for a way to exclude some files/folder and mass move files/folders with spaces and special characters from source to destination and then symlink after move completes. So far I have something like this.

cd $prev_dir
for i in `cat /scripts/files2move.txt`
   sed -i 's/\r$//' $i 
   echo $i
   cd $prev_dir
   mv $i $new_dir && ln -s $new_dir $prev_dir
   ln -s $i $new_dir $prev_dir
  • It would be nice to see an example of what you want your script to do. There is a few things that I don't fully follow in your code. For example, it looks as if you want to use sed to remove a carriage-return character, but it's unclear why this is part of a script that moves files. I'm also not sure about your call to ln with three pathname arguments, or why none of your variable expansions are quoted even though you say you work with filenames that has spaces and "special" characters in their names. – Kusalananda Aug 21 '20 at 6:58
  • am not saying it does not work with special characters I am saying thats what I want for everyone to keep in mind. The Goal to move files/folders and replace with symlink and to exclude files/folders on a list from this script. – erikthered Aug 21 '20 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.