You are on page 1of 2

How to exclude single file form deleting.

----------------------------------------------------------------------------------------------------server:/tmp/tt # ls -l
server:/tmp/tt # ls -lt | awk '{print $9}'
server:/tmp/tt # ls -lt | awk '{print $9}'| grep -v ibdiagnet.tar
server:/tmp/tt # for i in `ls -lt | awk '{print $9}'| grep -v ibdiagnet.tar`
> do
> ls -lt $i
> done
server:/tmp/tt # for i in `ls -lt | awk '{print $9}'| grep -v ibdiagnet.tar`; do
rm -f $i; done
server:/tmp/tt # ls -lt
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------server:/tmp/tt # ls -l
total 940
-rw-r--r-- 1 root root 303770
-rw-r--r-- 1 root root 31080
-rw-r--r-- 1 root root 2364
-rw-r--r-- 1 root root 66830
-rw-r--r-- 1 root root 7532
-rw-r--r-- 1 root root 5031
-rw-r--r-- 1 root root
109
-rw-r--r-- 1 root root 471040
-rw-r--r-- 1 root root 25131
-rw-r--r-- 1 root root 4822
-rw-r--r-- 1 root root 7711
server:/tmp/tt # ls -lt | awk

Aug 31 12:35
Aug 31 12:35
Aug 31 12:35
Aug 31 12:35
Aug 31 12:35
Aug 31 12:35
Aug 31 12:35
Aug 31 12:43
Aug 31 12:35
Aug 31 10:50
Aug 31 10:50
'{print $9}'

ibdiagnet.db
ibdiagnet.fdbs
ibdiagnet.log
ibdiagnet.lst
ibdiagnet.mcfdbs
ibdiagnet.pkey
ibdiagnet.sm
ibdiagnet.tar
ibdiagnet_ibis.log
ibdiagpath.log
ibdiagpath_ibis.log

ibdiagnet.tar
ibdiagnet.log
ibdiagnet.mcfdbs
ibdiagnet.sm
ibdiagnet_ibis.log
ibdiagnet.fdbs
ibdiagnet.pkey
ibdiagnet.lst
ibdiagnet.db
ibdiagpath.log
ibdiagpath_ibis.log
server:/tmp/tt # ls -lt | awk '{print $9}'| grep -v ibdiagnet.tar
ibdiagnet.log
ibdiagnet.mcfdbs
ibdiagnet.sm
ibdiagnet_ibis.log
ibdiagnet.fdbs
ibdiagnet.pkey
ibdiagnet.lst
ibdiagnet.db
ibdiagpath.log
ibdiagpath_ibis.log
server:/tmp/tt # for i in `ls -lt | awk '{print $9}'| grep -v ibdiagnet.tar`
> do
> ls -lt $i

> done
-rw-r--r-- 1 root root 2364 Aug 31 12:35 ibdiagnet.log
-rw-r--r-- 1 root root 7532 Aug 31 12:35 ibdiagnet.mcfdbs
-rw-r--r-- 1 root root 109 Aug 31 12:35 ibdiagnet.sm
-rw-r--r-- 1 root root 25131 Aug 31 12:35 ibdiagnet_ibis.log
-rw-r--r-- 1 root root 31080 Aug 31 12:35 ibdiagnet.fdbs
-rw-r--r-- 1 root root 5031 Aug 31 12:35 ibdiagnet.pkey
-rw-r--r-- 1 root root 66830 Aug 31 12:35 ibdiagnet.lst
-rw-r--r-- 1 root root 303770 Aug 31 12:35 ibdiagnet.db
-rw-r--r-- 1 root root 4822 Aug 31 10:50 ibdiagpath.log
-rw-r--r-- 1 root root 7711 Aug 31 10:50 ibdiagpath_ibis.log
server:/tmp/tt # for i in `ls -lt | awk '{print $9}'| grep -v ibdiagnet.tar`; do
rm -f $i; done
server:/tmp/tt # ls -lt
total 464
-rw-r--r-- 1 root root 471040 Aug 31 12:43 ibdiagnet.tar
server:/tmp/tt #
server:/tmp/tt #
server:/tmp/tt #

You might also like