Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Shell Script to Delete 1 folder and keep 5 Post 302429426 by dr.house on Monday 14th of June 2010 11:42:20 AM
Old 06-14-2010
A point to start from (?):

Code:
#!/bin/bash

TO_KEEP=5
ls . | grep -E '[0-9]{4}-[0-9]{2}-[0-9]{2}' >> BUFFER
ENTRIES=$( cat BUFFER | wc -l )
KICKOUT=$( cat BUFFER | sort -r | tail -n $(($ENTRIES-$TO_KEEP)) )
echo "$KICKOUT"
rm BUFFER

exit 0
# finis

Code:
[house@leonov] ls 2010*
2010-06-08/  2010-06-09/  2010-06-10/
2010-06-11/  2010-06-12/  2010-06-13/
[house@leonov] bash test.bash
2010-06-08

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script to delete folder based on text file information

I have been working on a script to list all the name's of a subfolder in a text file then edit that text file and then delete the subfolder base on the edited text file so far I have been able to do every thing I just talked about but can't figure out how to delete the subfolers base on a text file... (8 Replies)
Discussion started by: bone11409
8 Replies

2. Shell Programming and Scripting

Shell script delete log files from folder & subfolders on space usage

Hi, I am trying to write a shell script to delete logs generate by db when space in the folder reaches 70%. i am getting space values from db, find the files at OS and remove them by using a cron job runs every 5minutes. I have to keep the latest 5 files at any time, my problem is that log files... (3 Replies)
Discussion started by: saha
3 Replies

3. Shell Programming and Scripting

delete all the files in folder a which exist in folder b

Hi , I need a script which basically deltes all files in folder a which are alreasy present in folder b say folder a has files abc.txt pqr .txt and b has abc.txt pqr.txt rmr.txt then file abc.txt and pqr.txt from a should be deleted (6 Replies)
Discussion started by: viv1
6 Replies

4. UNIX for Dummies Questions & Answers

Shell script folder creation

hi can any one help me in shell scripting where in my requirement is to write a shell script where in if i run that script i should copy all the .doc files from one system to another systems within a network like from parent folders to child folder example parent folder A within parent folder... (5 Replies)
Discussion started by: afra
5 Replies

5. UNIX for Dummies Questions & Answers

Script to delete files in different folder

Hi Experts, i need a little help. i have different folder that contain files that need to be deleted. but those folder contains huge amoung of same with 3 different extention. what i used to do is to delete them using the rm commande rm *.ext *.ext1 *.ext3 what i want to do is to have... (1 Reply)
Discussion started by: yprudent
1 Replies

6. Shell Programming and Scripting

Script to delete files in a folder older than 2 days

hi i need a script to delete the files older than 2 days... if my input is say in a folder versions A_14122012.txt A_15122012.txt A_16122012.txt A_17122012.txt i want my output to be A_16122012.txt A_17122012.txt thanks in advance hemanth saikumar. (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

7. Shell Programming and Scripting

Ignore Folder in Shell Script ?

Hi, I currently use a script to extract *.deb files located in a Directory called "/var/mobile/Media/Downloads" The Problem is howver I want the script to ignore the folder: "/var/mobile/Media/Downloads/New Debs and Files" (it shall NOT decompile any of the files in that folder. Here is... (2 Replies)
Discussion started by: pasc
2 Replies

8. Shell Programming and Scripting

Shell script to copy files from on folder to another

I am trying to copy files with specific date and name to another folder. I am very new to shell scripting so i am finding it hard to do that. see the sample code i have written below. srcdir="/media/ubuntu/CA52057F5205720D/Users/st4r8_000/Desktop/office work/26 nov"... (13 Replies)
Discussion started by: Aqeel Abbas
13 Replies

9. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

10. Shell Programming and Scripting

Delete oldest folder based on folder named as date

Hi, I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content. for example... (3 Replies)
Discussion started by: humble_learner
3 Replies
SLUDGE Z-BUFFER MAK(1)					   SLUDGE Z-Buffer Maker Manual 				    SLUDGE Z-BUFFER MAK(1)

NAME
sludge-zbuffermaker - edit SLUDGE z-buffer files SYNOPSIS
sludge-zbuffermaker [zbufferfile.zbu] DESCRIPTION
This manual page documents briefly the sludge-zbuffermaker command. This manual page was written for the Debian distribution because the original program does not have a manual page. Instead, it has documentation in the html format; see below. FILES
${HOME}/.config/sludge-devkit/ This directory is used to store configuration files. BUGS
Please report bugs in the SLUDGE forum at http://opensludge.sourceforge.net. SEE ALSO
sludge-devkit(1), sludge-engine(1) The full SLUDGE documentation is included in the package sludge-doc. It is installed to /usr/share/doc/sludge/SLUDGE_Help.html. AUTHOR
Tobias Hansen <tobias.han@gmx.de> Wrote this manpage for the Debian system. COPYRIGHT
Copyright (C) 2011 Tobias Hansen This manual page was written for the Debian system (and may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 3 or (at your option) any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL-3. sludge-zbuffermaker 05/13/2012 SLUDGE Z-BUFFER MAK(1)
All times are GMT -4. The time now is 08:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy