Link to home
Create AccountLog in
Avatar of sdruss
sdruss

asked on

unix delete the oldest file

In unix environment need csh or ksh script that will mangae directory of files.  Only need the latest 10 log files, thus need script that removes the oldest file.
Avatar of Tintin
Tintin


ls -t|sed 1,10d|xargs rm -f

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Hanno P.S.
Hanno P.S.
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of sdruss

ASKER

Great good stuff.
The answer accepted doesn't match your request.
Tintin,
as far as I can see, he wanted to get "the oldest" file deleted.

Your solution deletes all but the first ten files. Your solution is
much more enhanced and quite elegant -- but unfortunately
seems a bit overcrafted for the original Q.