help writing rm script excluding specific titled dir


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help writing rm script excluding specific titled dir
# 1  
Old 01-15-2010
help writing rm script excluding specific titled dir

I am attempting to write a housecleaning script that does the following:

1) goes to a specific directory
2) deletes all contents of that directory but a specific directory within it.

So my users all keep and use the Shared directory in OSX. Within /Users/Shared there are also standard named directories i.e. Clients, Regulators, Prospects and other rif raf that makes it in there that shouldn't be in there.

Basically want to go into /Users/Shared and rm -Rf all contents that are not named Clients

i've tried a couple of scripts but am getting weird stdout from my terminal and the interior directories are not touched.

Code:
#!/bin/sh
LOCO=`dirname /Users/Shared/`
KEEPER=Clients
rm - Rf ${LOCO}/* == ${KEEPER}

stdout tells me that I'm basically calling dirs that don't exist. I'm sure that my syntax sux and looking for a nudge in the right dirECTION (hah couldn't help that)

thanks for your time,
nom

Last edited by Franklin52; 01-15-2010 at 05:49 PM.. Reason: Please use code tags!
# 2  
Old 01-15-2010
ls|grep -v Clients|xargs rm -rf
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Assign read write permission to the user for specific dir and it's sub dir and files in AIX

I have searched this quite a long time but couldn't find the right method for me to use. I need to assign read write permission to the user for specific directories and it's sub directories and files. I do not want to use ACL. I do not want to assign user the same group of that directories too.... (0 Replies)
Discussion started by: blinkingdan
0 Replies

2. Shell Programming and Scripting

Need help writing array for the specific need of shell script

I need shell script for the following specfic need, I'll get following output after running my program. I wanted every 50th row in the coloumn and take into array. For example input ============== 03 03 03 03 05 05 05 05 07 07 07 07 I wanted to extract 3,5,7 and store it in... (12 Replies)
Discussion started by: JITHENDER
12 Replies

3. Shell Programming and Scripting

Finding duplicates in a file excluding specific pattern

I have unix file like below >newuser newuser <hello hello newone I want to find the unique values in the file(excluding <,>),so that the out put should be >newuser <hello newone can any body tell me what is command to get this new file. (7 Replies)
Discussion started by: shiva2985
7 Replies

4. Shell Programming and Scripting

How to tar this dir excluding some files .au?

Hi all, Thanks for previous help. How to include this in script, I need to tar files which are present in /var/spool/cron/crontabs directory (used for crontab) excluding those files which are having extension .au /var/spool/cron/crontabs>>ls -ltr | grep -v .au total 438 -rw------- 1... (11 Replies)
Discussion started by: manalisharmabe
11 Replies

5. Shell Programming and Scripting

Help- writing to dir with no write permissions (script)

hello, I have a question regarding the below script.. I just simply trying to write to a file in directory that does not have write permissions but this is failing .. it still writes to it regardless .. Many thanks in advance.. #!/bin/bash #check if dir exists, if so write to it ... (5 Replies)
Discussion started by: Reb0rn
5 Replies

6. UNIX for Dummies Questions & Answers

Excluding a specific column from sed replacement

Hi, I would like to replace all 0's to 1's throughout my text file. However I do not want column 3 altered. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

7. UNIX for Dummies Questions & Answers

List files older that 7 days in a dir, excluding all subdirs

Hi, I would like to list all files, older than 7 days, in a directory, but exclude all subdirectories in the find command. If I use find . -type f -mtime +7 all files in the subdirs are also included. How can I exclude them? Regards, JW (6 Replies)
Discussion started by: jwbijl
6 Replies

8. Shell Programming and Scripting

Need help in writing a script to create a new text file with specific data from existing two files

Hi, I have two text files. Need to create a third text file extracting specific data from first two existing files.. Text File 1: Format contains: SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 4 21:06:34 2010 some text ............so on...and somwhere text like: Record 1:... (1 Reply)
Discussion started by: shashi143ibm
1 Replies

9. UNIX for Dummies Questions & Answers

can anybody help me out in writing the script for incrementing the specific field

can anybody help me out in writing the any script (awk,shell or perl script) for incrementing the specific field highlighted below /{/data/{/assetMetricsList//{1]/dailyCount,........./{/data/{/assetMetricsList//{100]/dailyCount It should be in below format in oneline seperated by commas ... (1 Reply)
Discussion started by: swapnak
1 Replies

10. Shell Programming and Scripting

writing files to a dir in round robin order

I have a list of directories. (say a1,a2,a3,a4,a5) I need to get the directory last modified and access the next one to put some files over there (say if a3 is the latest dir modified ie, last time files were put into a3, this time I need to move the files in a4)...and if a5 is the last modified... (6 Replies)
Discussion started by: kanchan_cp
6 Replies
Login or Register to Ask a Question