Sponsored Content
Top Forums Shell Programming and Scripting How to suppress the error while copying the file Post 302596371 by knight_eon on Tuesday 7th of February 2012 08:03:14 AM
Old 02-07-2012
And much better will be:

Code:
 
[[ -f src_file ]] && cp src_file dest_file 2>/dev/null

So with above code, even if you don't have the source file, the script won't call cp command unnecessary. Also, it gives you flexibility to trap the information about missing file as well if you call in nested if - else statement Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to suppress error messages in script

I am getting the following upon cat a file which is not present in directory. "cat: cannot open test1.txt" I need to process files and I want that this message should be suppressed. thx (5 Replies)
Discussion started by: helper2007
5 Replies

2. Shell Programming and Scripting

Suppress error message in unzip

I'm creating a bsh shell to unzip a file from one directory into another. The directory that holds the zip files has zip files constantly being added to it, so I am testing it before it does the unzip and more. Right now my code looks like this: unzip -tq $ZIP_PATH/$ZIP_NAME >/dev/null if ... (5 Replies)
Discussion started by: skwyer
5 Replies

3. Shell Programming and Scripting

Suppress error message in shell script

Hi All this is a simple script #! /bin/bash FileCnt=`ls -lrt $DIR/* | wc -l` echo $FileCnt how could i escape the error msg if there are no files in $DIR ls: /home/sayantan/test/files/cnt/*: No such file or directory 0 Looking forward for a quick reply Regards, Newbie... (3 Replies)
Discussion started by: newbie07
3 Replies

4. UNIX for Dummies Questions & Answers

No such file or directory error while copying files

Hi, I need to copy files from one dir to another dir. The list of filesnames to be moved are in a file called files2cp.log Script: #!/bin/ksh exec 0</home/amdocs/files2cp.log while read LINE do cp -i /iccs33/attach/"$LINE" /iccs30/attach/"$LINE" done The output is "No such... (6 Replies)
Discussion started by: srinirsr
6 Replies

5. Shell Programming and Scripting

How to suppress the file name when we check for disk space

How to supress the file name when we check for disk space ? I used this command : du -ks /home/dir1/dir2/file.csv it returns 13 /home/dir1/dir2/file.csv Please explain the options too (7 Replies)
Discussion started by: arukuku
7 Replies

6. Shell Programming and Scripting

Suppress Error Message

How can I suppress a error message being given by awk command in bash shell? (2 Replies)
Discussion started by: Prachi Gupta
2 Replies

7. Shell Programming and Scripting

How to suppress error in following command?

I have a file containing data in multiple columns. The colums are seperated by pipe (|). I need to extract information as below: myfile_20130929_781;10;100.00 where myfile.txt is the file name. 10 is the number of records in the file starting with 120 and 100.00 is the sum of 26th field of... (16 Replies)
Discussion started by: angshuman
16 Replies

8. AIX

Error while copying file on AIX

/oragriddb_01/app/oracle/product/11203> ct_14_2012_22_58_58/files/lib/libdbcfg11.so /oragrid_01/Grid_11203/lib/libdbcfg11.so < cp: /oragrid_01/Grid_11203/lib/libdbcfg11.so: Cannot open or remove a file containing a running program. Best regards, Vishal (2 Replies)
Discussion started by: Vishal_dba
2 Replies

9. Shell Programming and Scripting

Tcsh: How to suppress error messages.

Hallo, I wrote some script: 95% of the script's output consists of error messages like "mkdir: cannot create directory ‘final': File exists Exit 1" and "rm: No match. Exit 1". These messages are not harmful at all, but they make the output almost unreadable. How can I get rid of... (5 Replies)
Discussion started by: DanielDD
5 Replies

10. Shell Programming and Scripting

Error copying file using wildcard

Hi, cd /web/myf ls -ltr -rwxr-x--- 1 user1 Admin 17 Oct 7 15:53 mykey.db -rwxr-x--- 1 user1 Admin 21 Oct 7 15:53 test.shmore test.sh cd log01 pwd cp ../*.db .When i run the test.sh i get the below output / error. Output: /web/myf/log01 cp: cannot stat `../*.db': No such file... (5 Replies)
Discussion started by: mohtashims
5 Replies
AD(1)								   Netatalk 2.2 							     AD(1)

NAME
ad - Netatalk compatible UNIX file utility suite. SYNOPSIS
ad {ls | cp | mv | rm} [...] ad {-v | --version} DESCRIPTION
ad is a UNIX file utlity suite with Netatalk compatibity. AppleDouble files in .AppleDouble directories and the CNID databases are updated as appropiate. AVAILABLE COMMANDS
ad ls [-dRl [u]] {file|dir [...]} List files and directories. ad cp [-aipvf] {src_file} {dst_file} ad cp -R [-aipvf] {src_file|src_directory ...} {dst_directory} Copy files and directories. ad mv [-finv] {src_file} {dst_file} ad mv [-finv] {src_file|src_directory ...} {dst_directory} Move files and directories. ad rm [-Rv] {file|directory} ad -v|--version Show version. AD LS
List files and directories. Options: -d Directories are listed as plain files -R list subdirectories recursively -l Long output, list AFP info -u List UNIX info Long output description <unixinfo> <FinderFlags> <AFP Attributes> <Color> <Type> <Creator> <CNID from AppleDouble> <name> FinderFlags (valid for (f)iles and/or (d)irectories): d = On Desktop (f/d) e = Hidden extension (f/d) m = Shared (can run multiple times) (f) n = No INIT resources (f) i = Inited (f/d) c = Custom icon (f/d) t = Stationery (f) s = Name locked (f/d) b = Bundle (f/d) v = Invisible (f/d) a = Alias file (f/d) AFP Attributes: y = System (f/d) w = No write (f) p = Needs backup (f/d) r = No rename (f/d) l = No delete (f/d) o = No copy (f) Note: any letter appearing in uppercase means the flag is set but it's a directory for which the flag is not allowed. AD CP
Copy files and directories. In the first synopsis form, the cp utility copies the contents of the source_file to the target_file. In the second synopsis form, the contents of each named source_file is copied to the destination target_directory. The names of the files themselves are not changed. If cp detects an attempt to copy a file to itself, the copy will fail. Netatalk AFP volumes are detected by means of their ".AppleDesktop" directory which is located in their volume root. When a copy targetting an AFP volume is detected, its CNID database daemon is connected and all copies will also go through the CNID database. AppleDouble files are also copied and created as needed when the target is an AFP volume. Options: -a Archive mode. Same as -Rp. -f For each existing destination pathname, remove it and create a new file, without prompting for confirmation regardless of its permis- sions. (The -f option overrides any previous -i or -n options.) -i Cause cp to write a prompt to the standard error output before copying a file that would overwrite an existing file. If the response from the standard input begins with the character 'y' or 'Y', the file copy is attempted. (The -i option overrides any pre- vious -f or -n options.) -n Do not overwrite an existing file. (The -n option overrides any previous -f or -i options.) -p Cause cp to preserve the following attributes of each source file in the copy: modification time, access time, file flags, file mode, user ID, and group ID, as allowed by permissions. If the user ID and group ID cannot be preserved, no error message is displayed and the exit value is not altered. -R If source_file designates a directory, cp copies the directory and the entire subtree connected at that point.If the source_file ends in a /, the contents of the directory are copied rather than the directory itself. -v Cause cp to be verbose, showing files as they are copied. -x File system mount points are not traversed. AD MV
Move files and directories. Move files around within an AFP volume, updating the CNID database as needed. If either: o source or destination is not an AFP volume o source AFP volume != destination AFP volume the files are copied and removed from the source. Options: -f Do not prompt for confirmation before overwriting the destination path. (The -f option overrides any previous -i or -n options.) -i Cause mv to write a prompt to standard error before moving a file that would overwrite an existing file. If the response from the standard input begins with the character `y' or `Y', the move is attempted. (The -i option overrides any previous -f or -n options.) -n Do not overwrite an existing file. (The -n option overrides any previous -f or -i options.) -v Cause mv to be verbose, showing files after they are moved. AD RM
Remove files and directories. The rm utility attempts to remove the non-directory type files specified on the command line. If the files and directories reside on an AFP volume, the corresponding CNIDs are deleted from the volumes database. The options are as follows: -R Attempt to remove the file hierarchy rooted in each file argument. -v Be verbose when deleting files, showing them as they are removed. REPORTING BUGS
Report bugs to the Netatalk-devel list <netatalk-devel@lists.sourceforge.net>. SEE ALSO
dbd(1), apple_dump(1). Netatalk 2.2 02 Sep 2011 AD(1)
All times are GMT -4. The time now is 02:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy