Sponsored Content
Top Forums Shell Programming and Scripting shell script to delete directories... Post 302195666 by Stephan on Thursday 15th of May 2008 04:18:15 PM
Old 05-15-2008
shell script to delete directories...

Hi.

I'm trying to write a script that will delete all directories found, that are not named as a "number" (year)...

here is what i mean, let's say i have within /data/exports the following directories:

/data/exports/2000
/data/exports/2001
/data/exports/2002

/data/exports/daily/2000
/data/exports/monthly/2000

/data/exports/daily/2001
/data/exports/monthly/2001

/data/exports/daily/2002
/data/exports/monthly/2002

/data/exports/blahblah/something/another/etc

and so on...

I want to write a script, that will delete all directories within /data/exports/ but not the 2000,2001 and 2002 found at that first level. The 200x found within daily and etc i want gone though.

So i thought about writing up a script that would list all directories within /data/exports/ and those that are not numbers, do a rm -R on it...but i can't seem to get it right...

any thoughts, help appreciated.

Thanks.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need some help with a script to delete directories.

Hello, I need a hand with a script im trying to make. I have a directory /usr/db/mail with a bunch of subdirectories such as /usr/db/mail/domain1.com /usr/db/mail/domain2.com etc. etc. all of these directories in turn have sub directories of their own. What I need to do is search all of... (1 Reply)
Discussion started by: centrino
1 Replies

2. Shell Programming and Scripting

shell script to delete directories...

*Just realized that i posted this in the wrong forum. should have been in Shell, though it is on AIX... Hi. I'm trying to write a script that will delete all directories found, that are not named as a "number" (year)... here is what i mean, let's say i have within /data/exports the... (8 Replies)
Discussion started by: Stephan
8 Replies

3. Shell Programming and Scripting

Help with Shell Script displaying Directories

I am new to shell programming and have an assignment question which requires me to list the contents of the present working directory in 4 column format and highlight any subdirectories. It then requires me to develop the shell script to accept a directory name as a positional parameter (if no... (11 Replies)
Discussion started by: cjnd1988
11 Replies

4. Shell Programming and Scripting

Script to delete old directories

Hi I have 10 directories.I want to delete all the dicrectories except the three recent directories based on timestamp.I am new to BASH can u help me? (1 Reply)
Discussion started by: newuser_25
1 Replies

5. Shell Programming and Scripting

renaming directories with shell script

Hi All after looking around the website and various other resources I become stuck. I'm trying to rename directories from Firstname Initial Lastname to lastname,_firstname_initial so far ive got for f in {./} do rename -n 'y/A-Z/a-z/' * rename -n 's/\ /_/g' * ... (2 Replies)
Discussion started by: harlequin
2 Replies

6. Shell Programming and Scripting

Script to delete old directories

Hi, I have a requirement like, I need to create the directory with date and time stap (i.e YYYYMMDDHMS) every day end need to delete the old directories which is 12 months old. I have tested with following script cd /export/home/sbeeravo/; find . -type d -mtime +365 -exec rm -rf {} \; ... (2 Replies)
Discussion started by: ShirishaReddy
2 Replies

7. Shell Programming and Scripting

Script to delete files with an input for directories and an input for path/file

Hello, I'm trying to figure out how best to approach this script, and I have very little experience, so I could use all the help I can get. :wall: I regularly need to delete files from many directories. A file with the same name may exist any number of times in different subdirectories.... (3 Replies)
Discussion started by: *ShadowCat*
3 Replies

8. Shell Programming and Scripting

Script to go Into Directories and Find/Delete files

I have a task, I usually do manually, but with growing responsibilities I tend to forget to do this weekly, I want to write a script that automates this, but I cant seem to work it out in my head, I have the shell of it out, but need help, and you guys have helped me with EVERY problem I have... (5 Replies)
Discussion started by: gkelly1117
5 Replies

9. Shell Programming and Scripting

Need shell script to compare directories and delete files on target server

Hello, I need help in writing the shell script for below mentioned case. There are 2 servers(server A, server B). A cronjob syncs files between these 2 servers. Existing script is copying files from A to B. This is done using the command rsync. However, the files are not deleted... (2 Replies)
Discussion started by: SravaniVedam11
2 Replies

10. Shell Programming and Scripting

Script to delete sub directories with parameters

Hello, How would I write a BASH script to remove all sub directories in a root level directory that are older than 10 days, but exclude directories owned by certain users. I would need to run as a cron job once a week. Thank you -John (2 Replies)
Discussion started by: jbeaulau
2 Replies
PMEXP(1p)						User Contributed Perl Documentation						 PMEXP(1p)

NAME
pmexp - show a module's exports DESCRIPTION
Given a module name, this program identifies which symbols are automatically exported (in that package's @EXPORT), those which are optionally exported (in that package's @EXPORT_OK), and also lists out the import groups (in that package's %EXPORT_TAGS hash). EXAMPLES
$ pmexp Text::ParseWords Text::ParseWords automatically exports shellwords, quotewords, nested_quotewords, and parse_line Text::ParseWords optionally exports old_shellwords $ pmexp Text::Wrap Text::Wrap automatically exports wrap and fill Text::Wrap optionally exports $columns, $break, and $huge $ pmexp Fcntl Fcntl automatically exports FD_CLOEXEC, F_DUPFD, F_EXLCK, F_GETFD, F_GETFL, F_GETLK, F_GETLK64, F_GETOWN, F_POSIX, F_RDLCK, F_SETFD, F_SETFL, F_SETLK, F_SETLK64, F_SETLKW, F_SETLKW64, F_SETOWN, F_SHLCK, F_UNLCK, F_WRLCK, O_ACCMODE, O_APPEND, O_ASYNC, O_BINARY, O_CREAT, O_DEFER, O_DSYNC, O_EXCL, O_EXLOCK, O_LARGEFILE, O_NDELAY, O_NOCTTY, O_NONBLOCK, O_RDONLY, O_RDWR, O_RSYNC, O_SHLOCK, O_SYNC, O_TEXT, O_TRUNC, and O_WRONLY Fcntl optionally exports FAPPEND, FASYNC, FCREAT, FDEFER, FEXCL, FNDELAY, FNONBLOCK, FSYNC, FTRUNC, LOCK_EX, LOCK_NB, LOCK_SH, and LOCK_UN Fcntl export tag `Fcompat' includes FAPPEND, FASYNC, FCREAT, FDEFER, FEXCL, FNDELAY, FNONBLOCK, FSYNC, and FTRUNC Fcntl export tag `flock' includes LOCK_SH, LOCK_EX, LOCK_NB, and LOCK_UN BUGS
The output formatting should be nicer, perhaps using "format" and "write". SEE ALSO
pmeth(1), perlmod(1), Exporter(3). AUTHORS and COPYRIGHTS Copyright (C) 1999 Tom Christiansen. Copyright (C) 2006-2008 Mark Leighton Fisher. This is free software; you can redistribute it and/or modify it under the terms of either: (a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or (b) the Perl "Artistic License". (This is the Perl 5 licensing scheme.) Please note this is a change from the original pmtools-1.00 (still available on CPAN), as pmtools-1.00 were licensed only under the Perl "Artistic License". perl v5.10.1 2010-02-22 PMEXP(1p)
All times are GMT -4. The time now is 05:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy