Sponsored Content
Full Discussion: Delete Photos Script
Top Forums Shell Programming and Scripting Delete Photos Script Post 302513943 by Shell_Life on Thursday 14th of April 2011 11:13:49 AM
Old 04-14-2011
See if this works for you:

Code:
#!/usr/bin/ksh
typeset -i mCnt
ls -1 | sort > File_List
IFS="-"
while read mUser mSuffix
do
  if [[ "${mUser}" != "${mPUser}" ]]; then
    mCnt=1
  fi
  if [[ ${mCnt} -gt 10 ]]; then
    mFName=${mUser}'-'${mSuffix}
    echo "Now deleting <${mFName}>"
    rm -f ${mFName}
  fi
  mPUser=${mUser}
  mCnt=${mCnt}+1
done < File_List

 

4 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How can I convert photos extension?

Hi all I am working in UNIX O.S and I want to transfer any photos from UNIX O.S to Windows O.S . can any one tell me how can I do this ? (3 Replies)
Discussion started by: bintaleb
3 Replies

2. Red Hat

Need Script to ZIP/SAVE & then DELETE Log file & DELETE ZIPS older than 12 months

ENVIROMENT Linux: Fedora Core release 1 (Yarrow) iPlanet: iPlanet-WebServer-Enterprise/6.0SP1 Log Path: /usr/iplanet/servers/https-company/logs I have iPlanet log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I... (7 Replies)
Discussion started by: zachs
7 Replies

3. Shell Programming and Scripting

Script for creating symbolic links to my photos (*.JPG)

Hi, I have all my pictures as *.JPG and *.CR2 in the following folder structure: /media/a_2TB/pictures/year/year-month-day-hour/picture*.* But sometimes I added a subdirectory --> /media/a_2TB/pictures/year/year-month-day-hour/suba/picture*.*... (3 Replies)
Discussion started by: 8200
3 Replies

4. Shell Programming and Scripting

Script needed to delete to the list of files in a directory based on last created & delete them

Hi My directory structure is as below. dir1, dir2, dir3 I have the list of files to be deleted in the below path as below. /staging/retain_for_2years/Cleanup/log $ ls -lrt total 0 drwxr-xr-x 2 nobody nobody 256 Mar 01 16:15 01-MAR-2015_SPDBS2 drwxr-xr-x 2 root ... (2 Replies)
Discussion started by: prasadn
2 Replies
All times are GMT -4. The time now is 03:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy