![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to find a string inside files | yoavbe | Shell Programming and Scripting | 12 | 05-05-2008 01:19 PM |
| How to delete Directory and inside files using Find command | bmkreddy | SUN Solaris | 3 | 07-10-2007 02:35 PM |
| how to find an errored disk | raj.soladm | SUN Solaris | 2 | 08-28-2006 01:31 PM |
| how to find Script file location inside script | asami | Shell Programming and Scripting | 10 | 03-15-2006 12:57 AM |
| Find files in Directories | steiner | Shell Programming and Scripting | 4 | 04-02-2005 12:01 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Need script to find errored files inside directories
Hi people.
I working on a script to check for files that they are suposed not to be on the directory. I mean, inside of each directory it must have some files but some could be wrong, and i want to move the files that are wrong. Ex: CSPOTGET edpst/CargadoresSPOT Historicos_Spot_MDI.zip COBGET edpst/CargadorOmelBroker ??????.xls CORGET edpst/CargadorOmelReuters CarOmlReuts.xls On folder " edpst/CargadoresSPOT " must only have " Historicos_Spot_MDI.zip" On folder " edpst/CargadorOmelBroker " must only have files with " yymmdd.xls" , and no others. I imagine this "configuration" file where the 1st column is a variable, the second is the directory and the 3rd column is the file(s) of each directory. Did you understand what i'm wrote? osramos |
|
||||
|
You want to find files that DO NOT match the pattern, correct?
ksh allows you to do that: Code:
#!/bin/ksh # files that are not named Historicos_Spot_MDI.zip ls edpst/CargadoresSPOT/!(Historicos_Spot_MDI.zip) # ls edpst/CargadorOmelBroker/!(??????.xls) # ls edpst/CargadorOmelReuters/!(CarOmlReuts.xls) |
|
||||
|
Ok, it works.
But there are almost 50 directories, with some of them with 4 or 5 files to exclude ( not match ). Can do this with a FOR cycle or something similar? osramos Quote:
|
|
||||
|
What you are asking is to create a resultset that all files minus pattern1 minus pattern2
The only problem for this is that we will have to use grep -v. The file matching patterns become regular expressions Code:
??????.xls
# becomes regex:
[0-9]{6}\.xls
Code:
ls !(pattern) Code:
# generalized solution ls directory | grep -v -e 'regex1' -e 'regex2' -e 'regex3' |
|
||||
|
Oh, i see.
Another problem i have, assuming i'm using " ls !(pattern) ", is the shell i'm using. The server is a Windows Server but have installed CYGWIN and Bash doesn't recognize the " ! ". Is there other solution? Regards, osramos Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|