operation on a folder level


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting operation on a folder level
# 1  
Old 02-09-2009
operation on a folder level

hi,
need help in writing a script in perl.
requirement :
1. Search for the files in a particular folder
2. search for a string in the file names
3. Delete the file which matches the string.

Ex: if the folder is C:\TEST
and the folder has 5 files like
2009ABCG.txt
2009MNO.txt
5241AAA.txt
1111aaa.txt and
2009PQR.txt

the matching string is "2009", then i want to delete all the files with the names %2009% i.e files 2009ABCG.txt,2009MNO.txt and 2009PQR.txt should be deleted from the folder C:\TEST
# 2  
Old 02-09-2009
If you take a look at the help for the unlink function (perldoc -f unlink), you'll notice an example there using wildcards. Possibly the one-liner
Code:
$ perl -e 'unlink <C:\\TEST\\2009*.txt>;'

could do the job.
Or, since you're apparently on Windows, try
Code:
C:\TEST\> del 2009*.txt

# 3  
Old 02-10-2009
thanks a lot ... the first one worked..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

2. Red Hat

SSL certificate generation on OS level or application level

We have a RHEL 5.8 server at the production level and we have a Java application on this server. I know of the SSL certificate generation at the OS (RHEL) level but it is implemented on the Java application by our development team using the Java keytool. My doubt is that is the SSL generation can... (3 Replies)
Discussion started by: RHCE
3 Replies

3. UNIX for Dummies Questions & Answers

General question about folder level permissions

How is the level of access on a particular folder determined? I have heard (its just hearsay so am not particularly sure of it) that the access a particular user/group has to a low level directory is also affected by the level of access granted to the user/group on its parent directories. e.g. ... (1 Reply)
Discussion started by: jawsnnn
1 Replies

4. Shell Programming and Scripting

Folder level size monitoring

Hi All, I have a requirement to monitor the sub-directories under /home in a way that if the the folder size increases by 30 GB in a span of like an hour then it needs to send email alerts listing what as the actual size was and what's the current size which the subject listing the sub-directory... (25 Replies)
Discussion started by: Shailesh6
25 Replies

5. UNIX for Dummies Questions & Answers

Redirect with htaccess to upper level folder, how to?

Hello, Well I have a web with a very bad structure (a vBulletin forum) and I want it redirected to a newer folder in the same server but with a upper level folder. Current structure is: https://www.unix.com/vbulletin/upload/index.php And I want it to be:... (0 Replies)
Discussion started by: Rafaweb
0 Replies

6. Shell Programming and Scripting

Column operation : cosne and sine operation

I have a txt file with several columns and i want to peform an operation on two columns and output it to a new txt file . file.txt 900.00000 1 1 1 500.00000 500.00000 100000.000 4 4 1.45257346E-07 899.10834 ... (4 Replies)
Discussion started by: shashi792
4 Replies

7. UNIX for Dummies Questions & Answers

find files on first level folder

Hi: I have: folderA |----folderB |----folder1 |----folder2 |----folder3 |----folder3.1 Question: How can I find *.txt ONLY from /folderA/folderB/ and not the others folder1,2,3?? I tried: find... (8 Replies)
Discussion started by: iga3725
8 Replies

8. Solaris

Difference between run level & init level

what are the major Difference Between run level & init level (2 Replies)
Discussion started by: rajaramrnb
2 Replies

9. Cybersecurity

Ubuntu folder level security

I have installed ubuntu. And I have create users ans groups. Suppose if the user enter into through Putty SSH. He should have access only to home folder and cannot move to other than $HOME. User should not able to root files and /$ files. Kindly provide solution. Regards Vasanth kumar (3 Replies)
Discussion started by: vasanthrj
3 Replies

10. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies
Login or Register to Ask a Question