V
V
vTanke2015-07-01 12:28:04
linux
vTanke, 2015-07-01 12:28:04

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

6 answer(s)
S
Sergey, 2015-07-01
@vTanke

Bash, for loop:
[email protected]:[~/tmp/move]: for i in `ls ./for/`; do mv ./for/$i ./to/; done

M
Maxim Kovalenko, 2015-07-01
@maxxx_kovalenko

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.

D
D', 2015-07-01
@Denormalization

find + -mtime + -exec + sed

A
Azazel PW, 2015-07-01
@azazelpw

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

A
Alexey Cheremisin, 2015-07-01
@leahch

The simplest, if one file system, then do

mount --bind

S
ShamblerR, 2015-07-02
@ShamblerR

As far as I understand, he needs one-sided synchronization, and for this, just cp with the addition of a new one is enough.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question