0

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.

#!/bin/bash
prev_dir=/test
new_dir=/dirtest2
cd $prev_dir
for i in `cat /scripts/files2move.txt`
   do
   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
done
Nasir Riley
  • 10,665
  • 2
  • 18
  • 27
erikthered
  • 11
  • 2
  • First thing: [Why does my shell script choke on whitespace or other special characters?](https://unix.stackexchange.com/q/131766/108618) Second first thing: [Why you don't read lines with `for`](https://mywiki.wooledge.org/DontReadLinesWithFor). – Kamil Maciorowski Aug 21 '20 at 04:37
  • 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 06: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

0 Answers0