I am trying to write a bash script that creates new folders with the same name and structure as the directories on my server.
first I got all directories and sorted them by name:
allDirLocal=$(cd $dirLocal ; find -type d |sort)
allDirServer=$(ssh -t $remoteServer "cd $dirServer ; find -type d |sort")
then I compared them to find which directories are missing on my local drive:
newDirServer=$(comm -13 <(echo "$allDirLocal") <(echo "$allDirServer"))
and then I tried to create said Directories on my local machine:
for Dir in "$newDirServer" ; do mkdir $Dir ; done
However I end up with directories that look like this:
'exampleDir'$'\r' instead of just exampleDir
How do I fix this?
Edit: I don't want to create a directory tree from a txt file but from a variable, but I always end up with this weird format...
Edit: I literally just had to replace " " with ' ' to get rid of those escape signs in my directory names... It only took me a month to figure this out :P