Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ Automatic Clear date directory shell script     - Nodejs command-line program development tutorial (Programming)

- MySQL view (Database)

- Use calcurse schedule appointments and to-do in the Linux terminal (Linux)

- Linux shell scripts bubble sort (Programming)

- KVM QEMU virtual machine installation configuration under CentOS (Linux)

- Classical sorting algorithm - Selection Sort (Linux)

- RedHat Linux 7 build yum source server (Server)

- Some problems and countermeasures Linux system calls exist (Linux)

- How to Set Free SSH password on CentOS / RHEL (Linux)

- Several SQL Server data migration / Export Import Practice (Database)

- Android LayoutInflater source parsing (Programming)

- GCC and gfortran write MEX program (Matlab2012a) under Ubuntu 14.04 (Programming)

- OpenJDK7 source compiler installation on CentOS 6.5 (Linux)

- The hash function under OpenSSL (Linux)

- [Android] Eclipse does not update the Android SDK Manager solution [using GoAgent] (Programming)

- CentOS 6.5 / Linux restart network card being given Determining if ip address x.x.x.x is already in use (Linux)

- MySQL full-index scan bug (Database)

- Teach you how to ensure password security under the Linux operating system (Linux)

- Those functions under Linux you do not know the df command (Linux)

- Install apr support for Tomcat on Linux (Server)

 
         
  Automatic Clear date directory shell script
     
  Add Date : 2017-08-31      
         
       
         
  Many times the backup is often used to create folders based on the date for which the date folder below there are many sub-folders, remove the entire document for these dates, find looks bloated by combining rm or delete. This article provides a simple little script that can be embedded into other scripts, can be called directly, as described below for your reference.

1, the script content

[Root @ SZDB ~] # more purge_datedir.sh
#! / Bin / bash
# Author: Leshami

RemoveDir = / log / hotbak / physical
dt = `date +% Y% m% d -d" 3 day ago "`

for subdir in `ls $ RemoveDir`;
do
    if [ "$ {subdir}" \ < "$ {dt}"];
        then
        rm -rf $ RemoveDir / $ subdir> / dev / null
        echo "The directory $ RemoveDir / $ subdir has been removed."
    fi
done

2 Demo

[Root @ SZDB ~] # ls / log / hotbak / physical
20141203 20141210 20141217 20141224 20141231 20150107 20150114 20150125 tmp.sh
2,014,120,720,141,214 2,014,122,120,141,228 2,015,010,420,150,111 2,015,012,120,150,128

[Root @ SZDB ~] # ./purge_datedir.sh
The directory / log / hotbak / physical / 20141203 has been removed.
The directory / log / hotbak / physical / 20141207 has been removed.
The directory / log / hotbak / physical / 20141210 has been removed.
The directory / log / hotbak / physical / 20141214 has been removed.
The directory / log / hotbak / physical / 20141217 has been removed.
The directory / log / hotbak / physical / 20141221 has been removed.
The directory / log / hotbak / physical / 20141224 has been removed.
The directory / log / hotbak / physical / 20141228 has been removed.
The directory / log / hotbak / physical / 20141231 has been removed.
The directory / log / hotbak / physical / 20150104 has been removed.
The directory / log / hotbak / physical / 20150107 has been removed.
The directory / log / hotbak / physical / 20150111 has been removed.
The directory / log / hotbak / physical / 20150114 has been removed.
The directory / log / hotbak / physical / 20150121 has been removed.

[Root @ SZDB ~] # ls / log / hotbak / physical
2,015,012,520,150,128
     
         
       
         
  More:      
 
- Android and OpenCV2.4.4 build an image processing framework (2013 edition) (Linux)
- C ++ 11 smart pointers (Programming)
- IPTABLES configuration steps under Linux (Linux)
- MySQL multi-master multi-cluster deployment uses alive Galera (Database)
- C ++ How to determine the types of constants (Programming)
- Linux Command Tutorial: du command to view disk space (Linux)
- Linux iptables port mapping settings (Server)
- LVM mirrored logical volume to achieve (Linux)
- Linux, grep, sed usage (Linux)
- Let MySQL 5.6 support Emoji expression (Database)
- To teach you how to safely send mail (Linux)
- Linux system started to learn: how to view the contents of the seed on the Linux file (Linux)
- RPM package management under Linux (Linux)
- Cooling solutions Ubuntu system (Linux)
- Python3 multi-thread download codes (Programming)
- Ubuntu Slingscold (Linux)
- How to fix Ubuntu / Mint can not add PPA source of error (Linux)
- Linux MultiPath software implementation instructions (Linux)
- How to create a bootable USB disk to use MultiSystem on Ubuntu (Linux)
- Linux how to view the graphics models notebook (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.