How to delete selected files?
Assumed I have the following files:
test12.txt test13.txt test14.txt test15.txt I want to delete the first 3 files with one command. How to do that? |
rm test12.txt test13.txt test14.txt
magic. |
or
rm test1[234].txt Slightly less typing. |
Quote:
This is the intelligent solution! |
Quote:
|
rm test1{103-300}.txt
rm test1*.txt for num in $(seq 234 434); do rm test${num}.txt done find . -maxdepth 1 -name "test1*.txt" -delete |
Quote:
If something goes wrong you can always restore the accidentally deleted files from your backup (do you have a backup, don't you?). If you need to select files, based on numbering you can either use a character list as in the example by Tinkster, a numeric interval, shell's brace expansion or command substitution with seq. |
Quote:
|
OK, I still like my solution. It did what was asked. In terms of key presses, i'd do...
rm [tab]2[tab][tab]3[tab][tab]4[tab][enter] so 13 in total. for Tinks version that'd be: rm [tab][234][tab][enter] so 10... Hmm, maybe you do win. that's 2.4 calories you saved! |
All times are GMT -5. The time now is 08:33 PM. |