Sponsored Content
Full Discussion: rm question
Top Forums UNIX for Dummies Questions & Answers rm question Post 302098343 by SeanWuzHere on Saturday 2nd of December 2006 07:59:08 PM
Old 12-02-2006
Quote:
Originally Posted by System Shock
Let me get this straight.
You want to set a variable that will limit the number of files you can delete in the command line, ex:
if you set MAXFILES to 3, and you type something like
Code:
 delete file1 file2 file3 file4 file5

only file1 file2, and file3 will be deleted.

Is that what you are looking for?
Yeah. Something like that. Here is the code I have so far for the program. It kinda sorta works but either I'm doing something wrong or it's missing something or I dunno.


Code:
#!/bin/bash
# Program: myrm

if [ "$#" -le 0 ]
then
        echo "Not enough arguments"
        echo "Usage: myrm [arg1] [arg2] etc..."
        exit 1
fi

MAXFILES=""
FILECOUNT=$(ls | wc -l)

if [ -n "$MAXFILES" ]
then

        if [ "$FILECOUNT" = "$MAXFILES" ]
        then
                for i
                do
                        rm -rf $1
                        shift
                done

        elif [ "$MAXFILES" > "$FILECOUNT" ]
        then
                echo "Would you like to delete these files?"
                read choice

                case "$choice"
                in
                        y)      for i; do rm -rf $1; shift; done;;
                        n)      echo "Thank you, have a nice day";;
                        *)      echo "Invalid choice"
                                exit 2;;
                esac
        fi

elif [ -z "$MAXFILES" ]
then
        for i in $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
        do
                rm -rf $1
                shift
        done
        exit 0


fi

 

7 More Discussions You Might Find Interesting

1. Programming

Yet Another Question

Now that I have getch() to work, I have yet another problem. BTW, thank you for answering these questions, I do ask a lot, only because I am eager to know, what is a board used for anyways :) Ok, he's the problem... #include iostream.h #include conio.h int main() { char movement; ... (2 Replies)
Discussion started by: mbolthouse
2 Replies

2. Solaris

vi question

Im trying to edit a 113 meg file in VI and i get the error TMP FILE TOO LARGE. Does someone know how to get around this? Thanks! (1 Reply)
Discussion started by: BG_JrAdmin
1 Replies

3. UNIX for Dummies Questions & Answers

mv question

Hello if I like to move file from defined directories system to new directory that not contained any directories system structure . But I like to create the same file system structure as source directory for example : I have 2 directories: foo1 and foo2 foo1 have directories and foo2 have... (2 Replies)
Discussion started by: umen
2 Replies

4. UNIX for Dummies Questions & Answers

Question

hallo, ik heb hier een vraagje. hoeveel gebruikers kunnen er op 1 unix systeem. hopelijk antwoorden golle nu want ik moet da vinde voor school en die leerkracht zaagt. :p groetjes eu wacht wa was mijne nick ah ja vraagje groetjes vraagje ik kan geen engels dus antwoord liever in het... (1 Reply)
Discussion started by: vraagje
1 Replies

5. Shell Programming and Scripting

question about wc

Hey my friend was asking me if i knew a way to cout how many different words in a file. I told him no not off hand, but i was thinking about it, and i started to wonder also. I imagine this is probably pretty simple im just missing something, I keep confusing my self with how you would compair and... (16 Replies)
Discussion started by: yodadbl07
16 Replies

6. Hardware

question

How to add 3 moniters to a pc set up? (2 Replies)
Discussion started by: clicstic
2 Replies

7. AIX

df question

Hi, Can anyone please explain a little about df command. I have following question: Following example is showing % used as 4 where as total free blocks are 15.46 out of 16.00 MB blocks. df -m /test Filesystem MBblocks Free %Used Iused %Iused ... (5 Replies)
Discussion started by: itsabhi9
5 Replies
asadmin-delete-instance(1AS)					   User Commands				      asadmin-delete-instance(1AS)

NAME
delete-instance - deletes the instance that is not running. SYNOPSIS
delete-instance [--user admin_user] [--password admin_password] [--host localhost] [--port 4848] [--local=false] [--domain domain_name] [--passwordfile filename] [--secure|-s]instance_name Use the delete-instance command to delete the instance that you specify. The delete-instance command can be run both locally and remotely. To delete the instance locally, not requiring the administration server to be up and running, specify the --local option. To delete the instance remotely, the administration server must be running on the hostname and port number specified. The user authenticates using the password identified for the administration server. Additionally, the instance must already exist within the domain served by the adminis- tration server. Use this command with discretion since it is destructive and there is no undo. OPTIONS
--user administrative user associated for the instance. --password administrative password corresponding to the administrative user. --host host name of the machine hosting the administrative instance. --port administrative port number associated with the administrative host. --domain name of the domain. --local determines if the command should delegate the request to administrative instance or run locally. --passwordfile file containing passwords appropriate for the command (e.g., administrative instance). --secure if true, SSL/TLS to communicate with the administrative instance. OPERANDS
instance_name name of the instance to be deleted. Example 1: Using delete-instance in local mode asadmin> delete-instance --domain domain1 server1 Deleted Instance server1 successfully Where: the server1 instance for the domain1 domain is deleted on the local machine. Example 2: Using delete-instance in remote mode asadmin> delete-instance --user admin --passwordfile passwords.txt --host localhost --port 4848 server1 Deleted Instance server1 successfully Where: the server1 instance for the domain associated with the specified user, passwords in the password file, host, and port number is deleted on the remote machine. EXIT STATUS
0 command executed successfully 1 error in executing the command INTERFACE EQUIVALENT
Server Instance page asadmin-create-instance(1AS), asadmin-start-instance(1AS), asadmin-stop-instance(1AS), asadmin-restart-instance(1AS) J2EE 1.4 SDK March 2004 asadmin-delete-instance(1AS)
All times are GMT -4. The time now is 09:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy