Sponsored Content
Top Forums Shell Programming and Scripting Help need with remove command Post 302782295 by pinnacle on Monday 18th of March 2013 01:15:18 PM
Old 03-18-2013
Code:
    echo 'Preparing to remove the following files:'
    ec=1
    printf "\t%s\n" ${INPUTDIR:?'$INPUTDIR is not correctly set'}/${PATTERNA:?'$PATTERNA is not correctly set'}*
    if $(rm $INPUTDIR/$PATTERNA*); then
        printf "\t%s\n" $INPUTDIR/${PATTERNB:?'$PATTERNB is not correctly set'}*
        if $(rm $INPUTDIR/$PATTERNB*); then
            printf "\t%s\n" ${TEMPDIR:?'$TEMPDIR is not correctly set'}/$PATTERNB*
            if $(rm $TEMPDIR/$PATTERNB*); then
                printf "\t%s\n" ${CONTROLDIR:?'$CONTROLDIR is not correctly set'}/$PATTERNB*.cmd
                if $(rm $CONTROLDIR/$PATTERNB*.cmd); then
                    echo 'All Files Deleted Successfully!!'
                    ec=0
                fi
            fi
        fi
    fi
    if [ $ec -ne 0 ]; then
        echo 'Some Files Were Not Deleted!!'
    fi

The above code is failing when it finds no files with the specified pattern.
I used
Code:
rm -f

in that case the variable check we are doing to check if rm was successfull will not be any longer useful since
Code:
 rm -f

will always return 0.

Is there any other way to do this ?
And also if time permits could you help me with code to delete files that could have space in their name.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search and remove command

I want to run the 'locate' command and then remove what the command finds. My guess was, locate blahblah |rm -f but this does not work. Thanks! (3 Replies)
Discussion started by: jasonr
3 Replies

2. UNIX for Dummies Questions & Answers

command to remove last record on file

Hi, First time on the forum. I have converted some files using the Unix to DOS command but need to strip off the last record that is generated from this conversion that contains just a ^Z. Is there any command that would accomplish this without having to do stream editing? (4 Replies)
Discussion started by: mheinen
4 Replies

3. Shell Programming and Scripting

rm command not able to remove file

I have directory IXNPG7 under which i have seen file ads.c , ads.gif , ads.js and lots more with extension .html I tried to remove the Entire Directory with rm -Rf IXNPG7 but it is saying -- Directory Not empty can't remove Secondly i tried removing all the files first using rm *.*... (7 Replies)
Discussion started by: jambesh
7 Replies

4. UNIX for Dummies Questions & Answers

Find and remove command - can you tell me exactly what its doing?

find /app01/tomcat_local -name *jsp* -type f -exec rm -r {} \; I would assume the above is just deleting any *jsp* below the /app01/tomcat_local directory - is this correct as its seems to delete more than I expect.... (1 Reply)
Discussion started by: frustrated1
1 Replies

5. UNIX for Dummies Questions & Answers

inverse remove command

Hi All, Is there an option for 'rm' to "remove everything but these files"? For instance if I have: a.txt <-- I just want to remove this one a_1.txt a_2.txt Is there an option ? for this: rm -? *_*.txt Thanks, ScKaSx (4 Replies)
Discussion started by: ScKaSx
4 Replies

6. UNIX for Dummies Questions & Answers

Command to remove First and Last line from a File

I have a file from which the Header and the Trailer lines need to be removed. They are confirmed to be the first and the last lines in the file. I have tried a few commands, but not successful yet. It needs to be implemented urgently, hence any help is greatly appreciated. Raghu ----------... (1 Reply)
Discussion started by: ragz_82
1 Replies

7. AIX

Unable to remove files from rm command

I need to delete some files which are not getting removed not even from root user -rw-r----- 1 ptml tellin 0 Jul 26 19:23 temp.out1 -rw-r----- 1 ptml tellin 0 Jul 26 19:23 temp.out -rw-r----- 1 ptml tellin 2 Jul 26 19:23 prev -rw-r----- 1... (4 Replies)
Discussion started by: m_usmanayub
4 Replies

8. Shell Programming and Scripting

simple remove command -ksh

KSH A simple remove command is not workin for me. The user has all the access and the return code after remove command is 0. But I am still able to find the file. I have the code as below. tmplog=/tmp/$fl_nm.$$ main () { --set of statments rm -fr $tmplog RC=$? } (2 Replies)
Discussion started by: tostay2003
2 Replies

9. UNIX for Dummies Questions & Answers

cut or remove command

hi, I want to remove first word in all files where first and second word is seperated by comma. example: a file contains Apple,mango. i need only mango shoule be there in the file??? Apple, should be removed!!!!! can anyone help me out??? thanks in advance, Arun Manas:b: (2 Replies)
Discussion started by: arunmanas
2 Replies

10. Shell Programming and Scripting

Can not remove file using rm command

I have two questions: the first is I have a line of code: printf "What is the id of the patient getting GJB2 analysis : "; read id that stores a user input in a variable $id in the python directory c:/Users/cmccabe/Desktop/Python27/$id.txt Using rm I get the error cannot remove ... (21 Replies)
Discussion started by: cmccabe
21 Replies
ZOOMSH(1)							     Commands								 ZOOMSH(1)

NAME
zoomsh - ZOOM shell SYNOPSIS
zoomsh [-e] [-v loglevel] [commands...] DESCRIPTION
zoomsh is a ZOOM client with a simple command line interface. The client demonstrates the ZOOM API and is useful for testing targets. You may pass one or more commands to zoomsh. These commands are invoked first. OPTIONS
-e Makes zoomsh stop processing commands as soon as an error occur. The exit code of zoomsh is 1 if error occurs; 0 otherwise. -v loglevel Sets YAZ log level. EXAMPLES
If you start the yaz-ztest in one console you can use the ZOOM shell as follows: $ zoomsh ZOOM>connect localhost:9999 ZOOM>search computer localhost:9999: 7 hits ZOOM>show 0 1 1 Default USmarc 001 11224466 003 DLC 005 00000000000000.0 008 910710c19910701nju 00010 eng 010 $a 11224466 040 $a DLC $c DLC 050 00 $a 123-xyz 100 10 $a Jack Collins 245 10 $a How to program a computer 260 1 $a Penguin 263 $a 8710 300 $a p. cm. ZOOM>quit You can also achieve the same result by passing the commands as arguments on a single command line: $ zoomsh "connect localhost:9999" "search computer" "show 0 1" quit COMMANDS
connect zurl Connects to the target given by zurl. close [zurl] Closes connection to target given by zurl or all targets if zurl was omitted. show [start [count]] Displays count records starting at offset given by start. First records has offset 0 (unlike the Z39.50 protocol). quit Quits zoomsh. set name [value] Sets option name to value. get name Prints value of option name. help Prints list of available commands. SEE ALSO
yaz(7), yaz-ztest(8), Section "Building clients with ZOOM" in the YAZ manual. ZOOM home page[1]. NOTES
1. ZOOM home page http://zoom.z3950.org/ YAZ 4.2.30 04/16/2012 ZOOMSH(1)
All times are GMT -4. The time now is 09:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy