Answer the question
In order to leave comments, you need to log in
How to transfer files to linux competently?
There is a folder structure:
/home/odin/folder/
/home/dva/folder/
/home/tri/folder/
..
you need to transfer the archives appearing in these folders to the
/media/odin/
/media/dva/
/media structure /tri/
..
I want an expression in one line (or several lines), I know that, most likely, this can be done. But I don't know how. In which direction to dig?
Answer the question
In order to leave comments, you need to log in
Bash, for loop:
[email protected]:[~/tmp/move]: for i in `ls ./for/`; do mv ./for/$i ./to/; done
Try to sync them using rsync:
/usr/bin/rsync -Paz - /home/* /media
or only the contents of the odin,dva,tri folders
/usr/bin/rsync -Paz - /home/{odin,dva,tri} /* /media/{odin,dva,tri}
Empty folders with no content are not synced.
If you don't bother, then you can.
mkdir /script
touch /script/copy.sh
chmod +x copy.sh
the script itself.
===============
#!/bin/bash
path2copy="/home"
path2paste="/media"
log="/var/log/"
echo `ls -la "$path2copy " |awk {'print $9'}` > /tmp/file.list
for i in `cat /tmp/file.list`
do
mv $path2copy/$i $path2paste/
done
========== ============
crontab -e
0 0 * * * /script/copy.sh
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question