Your Ad Here

Sabtu, 21 Juni 2014

Unix Tip: SPECIFIC REMOVALS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

UNIX GURU UNIVERSE
UNIX HOT TIP

Unix Tip 3420 - June 21, 2014

http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


SPECIFIC REMOVALS

To remove every file in
the folder that is not
dated March:

rm ` ls -al | grep -v "Mar" | awk '{print $9}'`

Or a specific date in March:

rm ` ls -al | grep -v "Mar 28" | awk '{print $9}'`

Note: that this is a
dangerous command to issue
since it assumes that you
are consciously using it
on a directory which is
full of files that are out
of date or not belonging to
March or whatever.

(If this is not the case you
might get some undesirable
results.)

The other thing is that you
might want to keep more than
one month's worth of files.
You would then need to move
the files from the other month
out into a temporary subfolder
while you "clean" the top
folder. Then move them back
in. Also, note that you have
two types of single quote,
the first and last are from
the key under the escape key
and the one that is used to
delimit the awk print
statement is the one next to
the hash key. I have used this
command myself regularly with a
few extra pipes (to do certain
specific things which are
irrelevant here) in order to
clean out subdirectories where
the df is running at 100%!
This has been a time-saver
when I have had to log on to
different servers around the
world and do a regular purge.


THIS TIP IS NOT SUPPORT,
UGU ADVICES TESTING BE FOR
USING.




--------------------------------------------------------------------------
To Subscribe: http://www.ugu.com/sui/ugu/show?tip.subscribe
To Unsubscribe: http://www.ugu.com/sui/ugu/show?tip.unsubscribe
To Submit A Tip: http://www.ugu.com/sui/ugu/show?tip.today

==========================================================================
DISCLAIMER: All UNIX HOT TIPS ARE OWNED BY THE UNIX GURU UNIVERSE AND ARE
NOT TO BE SOLD, PRINTED OR USED WITHOUT THE WRITTEN CONSENT OF THE UNIX
GURU UNIVERSE. ALL TIPS ARE "USE AT YOUR OWN RISK". UGU ADVISES THAT
ALL TIPS BE TESTED IN A NON-PRODUCTION DEVELOPMENT ENVIRONMENT FIRST.

Unix Guru Universe - www.ugu.com - tips@ugu.com - Copyright 1994-2001
==========================================================================

Tidak ada komentar:

Posting Komentar

Your Ad Here
Free Automatic Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink Free Auto Backlink