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
glib-gettextize
glib-gettextize(1) User Commands glib-gettextize(1)
NAME
glib-gettextize - maintain the internationalization of a package that uses the GNU gettext command
SYNOPSIS
glib-gettextize [--copy ] [--force ] [package-directory]
DESCRIPTION
glib-gettextize copies several standard files into the specified package. These files must be included in every package that uses the GNU
gettext command. glib-gettextize should only be used when creating a GNOME application.
OPTIONS
The following options are supported:
--copy Copy the files instead of creating symbolic links. You can also use -c to specify this option.
--force Force new files to be created even if old versions of the files exist. You can also use -f to specify this option.
OPERANDS
The following operands are supported:
-package-directoSpecify the package directory in which glib-gettextize should run. If no directory is specified, glib-gettextize runs in
the current directory.
EXAMPLES
Example 1: Set Up the Internationalization Framework for a Package
example% glib-gettextize
In this example, glib-gettextize is run in the package base directory.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of glib-gettextize: NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Application exited successfully
>0 Application exited with failure
FILES
The following files are used by this application:
/usr/bin/glib-gettextizeThe command-line executable for the application.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWgnome-base-libs-share |
+-----------------------------+-----------------------------+
|Interface stability |Evolving |
+-----------------------------+-----------------------------+
SEE ALSO
gettext(1)
Latest version of the GNOME Desktop User Guide for your platform.
NOTES
Written by Erwann Chenede, Sun Microsystems Inc., 2003.
SunOS 5.10 2 Oct 2003 glib-gettextize(1)