Unanswered: copy file from one directory to another
echo "inizio copiofatt.sh" > ./elaboro/log.txt
for filein in `ls ../file_*`
echo "$filein" >> ./elaboro/log1.txt
for copia in `cat $filein`
echo "$copia" >> ./elaboro/log2.txt
echo "$file_da_copiare" >> ./elaboro/log3.txt
for sposta in `cat listadir`
if test -f /AOD_NEW/$sposta/$file_da_copiare
cp -p /AOD_NEW/$sposta/$file_da_copiare /AOD_NEW/archivio_fatture_plas
if test $? -ne 0
echo "! errore nella copia di $file_da_copiare in /AOD_NEW/$spo
sta !" >>./elaboro/err.txt
echo "- file $file_da_copiare trovato in /AOD_NEW/$sposta -" >>
# chmod 666 /AOD_NEW/archivio_fatture_plasmon/$copia
echo "fine elaborazione $filein" >>./elaboro/log.txt
echo "fine elaborazione" >> ./elaboro/log.txt
Good morning to all
My problem is this.
I wrote a shell that needs to copy from one directory to another one file.
This is the structure of my fs
"filein" (filein the variable contains the list of files in a directory. Each file is a pure text documents containing the names of files to copy.)
This is the content
"copia" is the variable that contains the name of the file to be copied.
The files are located in an "fs" divided into many directory
This is the list of the "fs"
drwxr-xr-x 2 root system 9029632 Aug 24 2011 2001 -01
drwxr-xr-x 2 root system 6024192 Aug 24 2011 2001 -02
drwxr-xr-x 2 root system 8518656 Aug 23 2011 2001 -1
drwxr-xr-x 2 root system 603136 Jul 23 2011 2001 -10
drwxr-xr-x 2 root system 594944 Jul 23 2011 2 001 -100
drwxr-xr-x 2 root system 30720 Aug 24 2011 2001 -1000
The list of these directories is contained in the variable "sposta"
My shell has to open the files one at a time of the variable "filein"
Take the name of the file contained in the variable "copia"
Look in every directory of the variable "sposta" the file and copy it to the directory
The shell works well if it finds the first file in the directory of the variable "copia" read all the directories before moving to the next file.
Sorry for my English.
I use a translator to write.
Is it possible for a $file_da_copiare to exist in more than one directory? If so, should the search loop "for sposta in `cat listadir`" exit as soon as a file is found, or should the last one found be the only valid one?