Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



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 !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-23-2009
Registered User
 

Join Date: Jun 2009
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
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  
Old 12-23-2009
root cause analyst
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,770
Thanks: 5
Thanked 78 Times in 75 Posts
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
Closed Thread

Bookmarks

Tags
grep, regular expression, xargs

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:49 AM.