Delete Files
1) I want to delete all files which have extention out from specific folder.
Which command I can use? Following files which I want to delete in one command 456.out 987.out 876.out ---- ----- 2) I want to delete the files older then specific date from a folder? Thanks in Advance Sajjad |
hi,
to delete use the rm command... for exmple : rm -f *.out, this will delete all the files with .out at the end without asking (-f option = force) if you have folders you whant to delete, use the -r option. ()recursive) for more information use the manual (man rm) i hope i could help you leg |
what about
2) I want to delete the files older then specific date from a folder? |
when I use the said command
rm -f *.out, the following error message dispaly [oracle@visiondb1 PROD_proddb]$ rm -f *.out bash: /bin/rm: Argument list too long |
To delete multiple files you need to use a wildcard, which is the * character. (Yes, it's your asterisk.) * means every possible string of numbers and letters, including spaces.
Examples: Delete all files in a directory: rm * Be very, very careful with this. If I want to delete everything in the /usr/bin/foo directory, I type: rm /usr/bin/foo/* Thus specifiying the directory. (It's unnecessary and paranoid, but I do it anyway, because I might one day want to type "rm -RF," which removes all files and all subdirectories, and I want to keep the good, safe habit.) To delete all files starting with the word "star" type: rm star* This will remove starfish, star.doc, star.conf.bak, star.html, etc. To delete all files that end in out, type rm *.out. Keep the period. Make sure you don't type rm *out because that will also remove shout, pout, standout, etc. Also, type man rm so you can learn about the "rm" command. You can also use the * with commands such as cp, ls, etc. I can't help you with removing things after a certain date. You'll have to write a script and I don't have time to fiddle with that tonight. To do it manually, you'll need to type ls -algFs which will give you a listing of all files with dates. You can probably do something like ls -algFs | grep 2003 or ls -algFs | grep "Jan 7" and get a list of old files. Alex |
argument too long???
*) uh, this is new for me... maybe in your system there are another options for rm... i'm using FC2. try without the -f option, of loock in the manual for the "force" option. *) you whant do delete files olther than "Date", for that i don't know a program. but what you can do is to sort the files by date ls -lt, or ls -c1t (to have only the files name) you could use something like this to make a textfile with the output of ls: ls -c1 -t > sort-list now do a ls -lt and compare and delete the lines of "sort-list", where newer files are. run: rm `cat sort-list` bye leg |
Hi Alex
I have used the command rm *.out. but the following error display [oracle@visiondb1 PROD_proddb]$ rm *.out. rm: cannot remove `*.out.': No such file or directory can you please tell me the exact command to remove files with extion out. thanks |
Take out the period. You typed:
rm *.out. Instead, type: rm *.out Alex |
hi Alex
when I type said command rm *.out the following error message dispaly [oracle@visiondb1 PROD_proddb]$ rm *.out bash: /bin/rm: Argument list too long [oracle@visiondb1 PROD_proddb]$ thanks |
try this:
for i in *.out ; do rm $i ; done |
I don't understand, please type the exact command
|
I just made some files with .out extensions and tried to remove them. The command
rm *.out worked perfectly. This makes me think that someone aliased the rm command to something silly. Try typing alias at the command prompt. This will show you a list of aliased commands. You may discover that "rm" has been connected to an incorrect command. Commands such as "rm" or "cp" that can affect files in a dangerous manner are usually aliased with the "-i" extension, so if you see output like this: alias rm="rm -i" then you're ok. If "rm" is not on the list you need to look elsewhere for the problem. On the other hand, if you see something that looks like this: alias rm="rm -i -t -N" then rm has been aliased improperly. In this case you should type: alias rm="rm -i" which will give you a sane "rm" command. Then try: rm *.out The other possibility is that you're working on a drive which someone else has mounted and on which you don't have proper permissions. This can cause some commands to behave erratically. In fact, I just got an identical error message (Argument list too long) trying to eject a CDROM drive as "alex" which I had mounted as "root." You may have to su to root, or contact your sysadmin. Alex |
the command is:
for i in *.out ; do rm $i ; done type it on a xterm or konsole (and in the right location, where your files are placed) |
Hi Alex
Thanks for your quick support I am log in with user root and try the alias and rm command. alias command shows the right result which u have mentioned but the rm command display same error message. the result of two commands are as [root@visiondb1 PROD_proddb]# alias alias cp='cp -i' alias l.='ls -d .[a-zA-Z]* --color=tty' alias ll='ls -l --color=tty' alias ls='ls --color=tty' alias mv='mv -i' alias rm='rm -i' alias which='alias | /usr/bin/which --tty-only --read-alias --show-do lde' [root@visiondb1 PROD_proddb]# rm *.out bash: /bin/rm: Argument list too long [root@visiondb1 PROD_proddb]# thanks |
hi
the command is: for i in *.out ; do rm $i ; done this command run sccussfully, but it prompt on every file before deletion. I want to delete all files with out extention without prompting. [root@visiondb1 PROD_proddb]# for i in *.out ; do rm $i ; don rm: remove `o165278.out'? y rm: remove `o165291.out'? y rm: remove `o165296.out'? y rm: remove `o165301.out'? thanks |
All times are GMT -5. The time now is 03:15 AM. |