How do you find and remove largest file without having to manually type the file name
Hi I'm only starting to learn Linux and i am stuck on this problem
I have found the largest file by using ls -S|head -1 But i don't know how to remove this file without manually typing the file name. |
Code:
ls -S | head -1 | xargs rm |
Thanks a million crabboy it worked a treat
|
Or you can use:
Code:
rm "$(ls -S | head -1)" |
I made a post on a similar topic just a few hours ago. ls is not usually the recommended tool for such things.
http://www.linuxquestions.org/questi...1/#post4531807 Using the same looping technique as I posted before, this would be safer, if a bit longer. Code:
lsize=0 |
All times are GMT -5. The time now is 04:09 AM. |