|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Proper Expression To Not Include A String...
I have a folder of scripts: Code:
bash:/folderpath/> ls beginFile.sh beginFileBackup.sh beginAnother.sh beginAnotherBackup.sh beginJunk.sh beginJunkBackup.sh I'd like to be able to call just one (beginFile.sh) using this type of scheme: Code:
#Run the beginFile script without the word "Backup" in it. echo /folderpath/beginFile[^Backup]*.sh | xargs -n1 sh #Run the rest of scripts with the exception of the beginFile.sh script. echo /folderpath/begin[^File[^Backup]]*.sh | xargs -n1 sh Also, what If I did it this way: I know it isn't right, but can anyone provide the correct syntax? Also what If I want to run the rest of the scripts, except the beginFile.sh and the *Backup.sh file (i.e. beginAnother.sh and beginJunk.sh)? Code:
ls /folderpath | grep 'begin[^File.sh]' | xargs -n1 sh Would the expression change because I'm using grep? Thanks in advance for all answers. Last edited by mrwatkin; 12-23-2009 at 03:43 PM.. |
| Sponsored Links | ||
|
|
|
#2
|
|||
|
|||
|
If you set extglob (shopt) to yes in bash, or standard in ksh93 you can do this: Just run beginfile: Code:
/folderpath/beginFile.sh run he rest of the scripts: Code:
/folderpath/!(beginFile.sh) run the rest of the scripts, except the beginFile.sh and the *Backup.sh file Code:
/folderpath/!(beginFile.sh|*Backup.sh) Last edited by Scrutinizer; 12-23-2009 at 04:16 PM.. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| grep, regular expression, xargs |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| regular expression format string in one line. | jimmy_y | Shell Programming and Scripting | 2 | 11-02-2009 09:30 PM |
| Help: Regular Expression for Negate Matching String | DrivesMeCrazy | Shell Programming and Scripting | 4 | 06-22-2009 01:24 PM |
| validate a string against a regular expression | hcclnoodles | Shell Programming and Scripting | 1 | 04-12-2009 05:33 PM |
| Regular Expression - match 'b' that follows 'a' and is at the end of a string | machinogodzilla | UNIX for Dummies Questions & Answers | 2 | 01-04-2009 03:14 PM |
| How do I include "$" in a string | beilstwh | Shell Programming and Scripting | 2 | 06-08-2006 08:59 AM |