I am trying to move some directories and files within said directories to a new directory, the code I am using utilises a for loop and checks the content of a txt file which is used to determine what it is we want to move. I only insert the directory names into the txt file.
The code only seems to move the content within the directories and not the directory and it's content.
#!/bin/bash
cp "files_for_moving.txt" /Users/johndoe/project/for_moving
cd /Users/johndoe/project/for_moving
FILESFORMOVING="files_for_moving.txt"
LINES=$(cat $FILESFORMOVING)
echo $LINES
for i in $LINES
do
echo 'running the mover script'
cp -R $i/ ../simple_done_updated/
done
cd /Users/johndoe/project
CodePudding user response:
You should try removing the first /
from:
cp -R $i/ ../simple_done_updated/
to:
cp -R $i ../simple_done_updated/