Sponsored Content
Full Discussion: Delete files if they exist
Top Forums Shell Programming and Scripting Delete files if they exist Post 302252367 by pederlol on Wednesday 29th of October 2008 09:51:50 AM
Old 10-29-2008
Delete files if they exist

In a directory a number of files named res0.om res1.om ... resN.om

where N can be any unknown number between 1 and 999

Please help me filling out the gaps in the following csh script:

I need to delete all files exept res0.om The easy way is

rm res1*
rm res2*
rm res3*
rm res4*
rm res5*
rm res6*
rm res7*
rm res8*
rm res9*

but that gives a lot of ugly error messages in case N < 9.

Can i use something like:

if (res9* exist) rm res9*

?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare data in 2 files and delete if file exist

Hi there, I have written a script called "compare" (see below) to make comparison between 2 files namely test_put.log and Output_A0.log #!/bin/ksh while read file do found="no" while read line do echo $line | grep $file > /dev/null if then echo $file found found="yes" break fi... (3 Replies)
Discussion started by: lweegp
3 Replies

2. Shell Programming and Scripting

perl: When dealing with files that do not exist

I have a process run weekly where I must convert data formats for about thirty files. I read a text file that provides all of the filenames and switch settings. My perl code is: for ($j = 1; $j <= $k; $j++) { open(FIN2,$fin2) || die "open: $!"; do other stuff } Every once in... (2 Replies)
Discussion started by: joeyg
2 Replies

3. UNIX for Dummies Questions & Answers

testing if files exist

I am trying to test arguments to see if they are files in any directory. I have : but it's not working (7 Replies)
Discussion started by: skooly5
7 Replies

4. Shell Programming and Scripting

delete all the files in folder a which exist in folder b

Hi , I need a script which basically deltes all files in folder a which are alreasy present in folder b say folder a has files abc.txt pqr .txt and b has abc.txt pqr.txt rmr.txt then file abc.txt and pqr.txt from a should be deleted (6 Replies)
Discussion started by: viv1
6 Replies

5. Shell Programming and Scripting

Find out whether files exist.

I have the following data stored in a file. 1 /home/file13 /home/file2 2 /home/file41 /home/file654 3 /home/file61 /home/file45 4 /home/file81 /home/file43 ... I want to print the first column provided the files represented by the second and third column exist. How to do that? (3 Replies)
Discussion started by: kevintse
3 Replies

6. Shell Programming and Scripting

Script to mail if files do not exist

Hi all! I need some help with a script, but I want to make it better, my script prints the last two files on each directory: echo " " echo "******************* mediation_sgsn:***********************" ls -lrt /moneta_collected03/mediation_sgsn | tail -2 echo " " echo... (6 Replies)
Discussion started by: fretagi
6 Replies

7. Shell Programming and Scripting

File exist for multiple files

Hi, I am unable to achieve the file exist conditions if there are multiple files same similar name for e.g. in a $Direct i am having files like aus.txt aus.txt_pr aus.txt_2012 i need to put a file exist condition like which is not working then echo "File present" but the... (9 Replies)
Discussion started by: rohit_shinez
9 Replies

8. UNIX for Dummies Questions & Answers

Does rsync check and ignore files that already exist?

Hi, We have two (2) servers named primary and standby. There is a directory named /db01/archive that we need to keep in-sync. Files get transferred from primary and standby. Sometimes when we do a failover or when there is a network issue, some files fail to get transferred. I want to use... (3 Replies)
Discussion started by: newbie_01
3 Replies

9. UNIX for Beginners Questions & Answers

Check if 10 files exist

Hi All, Whenever i get 10 files(file names like sales*) then another file need to create. May i know how to implement this in KSH. (4 Replies)
Discussion started by: siddireddy
4 Replies

10. Shell Programming and Scripting

Find command when there exist many files

I want to run find and wondering if it struggles when there are many files. I have tried and does not seem to complain. Is this correct? (8 Replies)
Discussion started by: kristinu
8 Replies
PG_RESULT_ERROR(3)														PG_RESULT_ERROR(3)

pg_result_error - Get error message associated with result

SYNOPSIS
string pg_result_error (resource $result) DESCRIPTION
pg_result_error(3) returns any error message associated with the $result resource. Therefore, the user has a better chance of getting the correct error message than with pg_last_error(3). The function pg_result_error_field(3) can give much greater detail on result errors than pg_result_error(3). Because pg_query(3) returns FALSE if the query fails, you must use pg_send_query(3) and pg_get_result(3) to get the result handle. PARAMETERS
o $result - PostgreSQL query result resource, returned by pg_query(3), pg_query_params(3) or pg_execute(3) (among others). RETURN VALUES
Returns a string. Returns empty string if there is no error. If there is an error associated with the $result parameter, returns FALSE. EXAMPLES
Example #1 pg_result_error(3) example <?php $dbconn = pg_connect("dbname=publisher") or die("Could not connect"); if (!pg_connection_busy($dbconn)) { pg_send_query($dbconn, "select * from doesnotexist;"); } $res1 = pg_get_result($dbconn); echo pg_result_error($res1); ?> SEE ALSO
pg_result_error_field(3), pg_query(3), pg_send_query(3), pg_get_result(3), pg_last_error(3), pg_last_notice(3). PHP Documentation Group PG_RESULT_ERROR(3)
All times are GMT -4. The time now is 01:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy