I want to use the rm command to delete files in a directory. But I want to be able to set a variable that says how many arguments it will delete. So for instance, if I set a variable to null,.. (i.e. MAXFILES="") then it will just delete all the arguments. But if I set MAXFILES=2 for instance, then it will delete only 2 arguments. I'm writing a program to do this, and there are other specifications too,.. but I think I have most of it figured out but I can't seem to get past this one hurdle. Any thoughts? Great thanks in advance to any advice on this.
Btw,... before I start writing the program, I want to be able to practice setting the variable and then using that variable just using the command at the command prompt. In other words, I want to be able to just do something like...
$ MAXFILES=""
$ rm arg1 arg2 arg3
$
or
$ MAXFILES=2
$ rm somethinggoeshere (and it deletes the files per the number of arguments defined in the variable above.)
This way it will hopefully sink in through my thick cranium on how this is working.
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
only file1 file2, and file3 will be deleted.
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
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.
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.
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.
Here's my revised version which works the way I need it to for the most part.
Then I just do something like this:
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.
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)
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)
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)
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)
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)