|
| ||||||||||
| Tags: bash commands, linux, open source, script, unix |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Bash command to delete entire Files from folder
|
|
#2
| ||||
| ||||
| Re: Bash command to delete entire Files from folder
Hello friend, I am not the continuous user of UNIX operating system. But I had something idea related to it. You can remove the entire files without deleting the specific folder by the following Bash command: find . -type f -name "*{}*" -exec rm -fr {} \; You can also test it with the help of IS command, it can be less risky to you: find . -type f -name "*{}*" -exec ls {} \; The command which I had specified is not yet tested. Because I don’t have the UNIX systems to test this bash commands. Test it let me know what happens? |
|
#3
| ||||
| ||||
| Re: Bash command to delete entire Files from folder
Suppose I have being using the 30 other folders, where I have to normally type the folders pathname each and every time. Can I modify the command to remove the entire files which is present in the specific folders? The folder is in the following folder: A-ABC-20101512-0001 A-ABC-20100322-0002 A-ABC-20100482-0003 …………. Note that the numbers are in the format DDMMYY-NN. I can write the command in the following format: find A-ABC-DDMMYY-NN/folder/subfolder -type f –delete. The given command can be adjusted to the files which you want to remove for each other 30 folders in single command. Without operating it for the other different folder.
__________________ Ram requirement for various OS |
|
#4
| ||||
| ||||
| Re: Bash command to delete entire Files from folder
There is no need to search for the command and then execute the command. The command I can give to the system whose content will get deleted from the folders is $ rm -fR "{}*". This command will remove all the files and also directories from the specific folders. –f command represents the system to do the force remove and –R command is recursive. If you want to remove the files interactively then you can ask for the confirmation for each and every file, make use of the –i option in place of the –f option. Try it this will help you. |
|
#5
| |||
| |||
| Re: Bash command to delete entire Files from folder
I think kattman is correct. In Linux/UNIX shell, the command to empty out a directory is Code: cd "/path/to/directory" rm -rf * If you are looking for bash-like commands on windows, biterscripting is your best bet. The commands in biterscripting are Code: cd "/path/to/directory" system -s "del /F /Q *" |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Bash command to delete entire Files from folder" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to delete files that appear in find command's output in Linux | jAYASENA | Operating Systems | 6 | 27-05-2011 10:20 AM |
| Linux bash script with the command w | Trini Alvarado | Operating Systems | 4 | 22-03-2010 12:11 PM |
| bash visudo command not found | Sheena_thakkar | Operating Systems | 3 | 19-11-2009 08:34 PM |
| Print all files in a folder in a single command In Windows Xp | Mac rumor | Tips & Tweaks | 1 | 13-10-2009 05:53 PM |
| How to delete folder from the command prompt? | Jack | Vista Help | 7 | 07-03-2008 10:13 AM |