12-14-2008
Bash Copy-Move file problem
Hello,
I made a script to copy files from one directory to another and move file after the copy is done. When files are present in the source directory there is no problem but when no file are present I'm getting an error.
Please help !!
---------------------
#!/bin/bash
source_txt="/Users/lsimoneau/Desktop/test/pc/textes/"
destination_txt="/Users/lsimoneau/Desktop/test/destination/textes/"
archives_txt="/Users/lsimoneau/Desktop/test/z_archives_txt/"
log_txt="/Users/lsimoneau/Desktop/copietxt.log"
extenstion_txt="*.[tT][xX][tT]"
date >> $log_txt
list=`ls "$source_txt"$extenstion_txt 2> /dev/null`
old_ifs=${IFS};IFS=$' '
echo $list | echo `wc -l` "files to copy." >> $log_txt
echo $list | while read file; do
echo $file >> $log_txt
cp -f "$file" $destination_txt
mv -f "$file" $archives_txt
done
IFS=${old_ifs}
date >> $log_txt
_________
log when files are copied
Sun Dec 14 12:39:52 EST 2008
2 files to copy.
/Users/lsimoneau/Desktop/test/pc/textes/fichier01 - copie 01 09-03-47.txt
/Users/lsimoneau/Desktop/test/pc/textes/fichier01 - copie 01 09-04-59.txt
Sun Dec 14 12:39:52 EST 2008
_________
log when files are not present
Sun Dec 14 12:40:04 EST 2008
1 files to copy.
Sun Dec 14 12:40:04 EST 2008
cp: fts_open: No such file or directory
mv: rename to /Users/lsimoneau/Desktop/test/z_archives_txt/: No such file or directory
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I am trying to create files with special characters in its filenames for testing purposes. This is on a Linux RHEL4 but this should also be applicable on a Unix shell.
I am able to create files with special characters in the filenames...e.g.
cp -pv foo.gif \*special.gif
cp -pv foo.gif \... (6 Replies)
Discussion started by: sqa777
6 Replies
2. UNIX for Dummies Questions & Answers
I am trying to move a file that is in the root directory. I suspect it is an old file created by someone when the system was installed. I am testing accessing the file by doing a copy but the command does not find the file.
I am operating as root. We are HP-UX B.11.23
I do long listing and... (3 Replies)
Discussion started by: phcorn
3 Replies
3. Shell Programming and Scripting
Hello experts,
I'm doing a shell script that able to copy or move files.
My situation is i have a drive ( lets say its S drive) where its receive all the files from mainframe
i need to copy all the file from S drive to T drive. but only those files that are finished copied from mainframe... (5 Replies)
Discussion started by: CelvinSaran
5 Replies
4. UNIX for Dummies Questions & Answers
Hello All,
i have a really strange copy paste problem. When I write some loops in an editor for example:
for j in 1 2 3
do
echo "$j"
done
and I want to paste it to the shell, the result in the shell is:
for j in 1 2 3; do e;
other commands work fine and if a copy paste... (4 Replies)
Discussion started by: creamcheese
4 Replies
5. Shell Programming and Scripting
Hi All,
I have a simple shell script to move .txt file(s) from a source directory one after another to the destination. The source directory is shared to windows using samba. The source files are arriving continuously and approx size is 10-15 KB. Some time the file size reached upto 100 KB and... (9 Replies)
Discussion started by: sraj142
9 Replies
6. Solaris
Hey everyone!. I have a problem with a file that doesn't allow any operation on it. I can't rm,mv,cp nor any other operation to it, I get the following errors:
bash-2.05# mv ora_2527.aud /bkp
mv: cannot access ora_2527.aud
bash-2.05# cp ora_2527.aud /bkp
cp: cannot access ora_2527.aud... (4 Replies)
Discussion started by: dragonov7
4 Replies
7. Shell Programming and Scripting
I'm having problems with my bash script. I would like to find a file matching today's date in the filename, i.e. my_file_20120902.txt and then move it to a different directory, i.e. /tmp. Thanks. (1 Reply)
Discussion started by: jamesi
1 Replies
8. Red Hat
Hi all,
I'm Using Centos 6.4
/opt/my_aplication/entry/data/0/
There are Thousands of files in this Directory, Only i need to copy or move the apache User's file from this to /tmp/backup , I have listed apache user's file using find . -user apache -type f , its gave me the only apache... (2 Replies)
Discussion started by: babinlonston
2 Replies
9. Shell Programming and Scripting
I have a directory /home/cmccabe/nfs/exportedReports that contains multiple folders in it. The find writes the name of each folder to out.txt. A new directory is then created in a new location /home/cmccabe/Desktop/NGS/API, named with the date. What I am trying to do, unsuccessfully at the moment,... (7 Replies)
Discussion started by: cmccabe
7 Replies
10. Shell Programming and Scripting
I am trying to mv each of the .vcf files in the variants folder to the folder in /home/cmccabe/f2 that the .vcf id is found in file. $2 in file will always have the id of a .vcf in the variants folder. The line in blue staring with R_2019 in file up to the -v5.6 will always be an exact match to a... (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT DEBIAN
ecaccess-file-copy
ECACCESS-FILE-COPY(1p) User Contributed Perl Documentation ECACCESS-FILE-COPY(1p)
NAME
ecaccess-file-copy - Copy an ECaccess File
SYNOPSIS
ecaccess-file-copy -version|-help|-manual
ecaccess-file-copy [-debug] [-erase] source-ecaccess-file target-ecaccess-file
DESCRIPTION
Copy the source-ecaccess-file to the target-ecaccess-file.
The source-ecaccess-file and target-ecaccess-file are in the form [domain:][/user-id/]path. Please read the "Shell commands -> File
Management" section of the "ecaccess" guide for more information on the ECaccess File System.
ARGUMENTS
source-ecaccess-file
The source ECaccess File name for the copy.
target-ecaccess-file
the target ECaccess File name for the copy.
OPTIONS
-erase Delete the source file once the copy has completed successfully. By default the source file is not deleted.
-version
Display version number and exits.
-help Print a brief help message and exits.
-manual Prints the manual page and exits.
-debug Display the SOAP messages exchanged.
EXAMPLES
ecaccess-file-copy ec:bin/a.out c1a:/c1a/tmp/systems/xyz/a.out
Copy the a.out File in the ECFS bin directory of the authenticated user to the "/c1a/tmp/systems/xyz" directory on c1a.
SEE ALSO
ecaccess-file-delete, ecaccess-file-get, ecaccess-file-mget, ecaccess-file-modtime, ecaccess-file-mput, ecaccess-file-rmdir, ecaccess-file-
chmod, ecaccess-file-dir, ecaccess-file-mdelete, ecaccess-file-mkdir, ecaccess-file-move, ecaccess-file-put, ecaccess-file-size and
ecaccess.
perl v5.14.2 2012-04-16 ECACCESS-FILE-COPY(1p)