Sponsored Content
Full Discussion: rm question
Top Forums UNIX for Dummies Questions & Answers rm question Post 302098349 by SeanWuzHere on Saturday 2nd of December 2006 11:04:52 PM
Old 12-03-2006
Quote:
Originally Posted by kapilraj
why do you want to do this ?

rm file1 file2 will delete file1 and file2 , rm * will delete everything. I can not undestand your requirement or this is a stupid requirement.

Regds,

Kaps
Yeah,.. I guess when we are first learning something people give us stupid questions to figure out. LOL. Believe me,.. I have way better things I'd rather spend my Saturday night doing but I have to get this finished. Also,.. just remember,.. this is probably really easy for you because you are probably an expert with this but I am just a n00b so there's a lot that doesn't make sense to me yet. But I'm getting better and better at it everday. Smilie

Well, anyway,.. I think I have it all figured out for the most part. Now I just have to make it so that if the number of arguments exceed the number specified in MAXFILES, then it will ask me to confirm the deletion. That shouldn't be too hard. Anyway,.. thanks all for the great help. Smilie

Here's my revised version which works the way I need it to for the most part.

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

if [ -z "$MAXFILES" -a "$#" -ge 1 ]
then
        for MAXFILES in $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}
        do
                echo "deleted$MAXFILES"
                shift
        done
        exit 1
fi

if [ -n "$MAXFILES" -a "$#" -ge 1 ]
then
        MAXFILES="$*"
        rm -rf $MAXFILES
fi

Then I just do something like this:

Code:
$ MAXFILES=56 ./myrm f1 f2 f3 f4
# then it deletes the 4 files because they are less than the amount specified in MAXFILES.
or
$ MAXFILES= ./myrm f1 f2 f3 f4

blah blah blah

Also,.. I have just an echo command in the top section just to make things easier. I'll go back and put the correct commands in there later. I just mainly needed to figure out HOW to do it and I think I got it now.
 

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
DIFF(1) 						      General Commands Manual							   DIFF(1)

NAME
diff - print differences between two files SYNOPSIS
diff [-c | -e | -C n] [-br]file1 file2 OPTIONS
-C n Produce output that contains n lines of context -b Ignore white space when comparing -c Produce output that contains three lines of context -e Produce an ed-script to convert file1 into file2 -r Apply diff recursively to files and directories of EXAMPLES
diff file1 file2 # Print differences between 2 files diff -C 0 file1 file2 # Same as above diff -C 3 file1 file2 # Output three lines of context with every diff -c file1 file2 # Same diff /etc /dev # Compares recursively the directories /etc and /dev diff passwd /etc # Compares ./passwd to /etc/passwd DESCRIPTION
the same name, when file1 and file2 are both directories" difference encountered" Diff compares two files and generates a list of lines telling how the two files differ. Lines may not be longer than 128 characters. If the two arguments on the command line are both directories, diff recursively steps through all subdirectories comparing files of the same name. If a file name is found only in one directory, a diagnostic message is written to stdout. A file that is of either block special, character special or FIFO special type, cannot be compared to any other file. On the other hand, if there is one directory and one file given on the command line, diff tries to compare the file with the same name as file in the directory directory. SEE ALSO
cdiff(1), cmp(1), comm(1), patch(1). DIFF(1)
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy