![]() |
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 |
| 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| df, grep, wild card | itik | AIX | 2 | 01-24-2008 10:41 AM |
| wild card & regular expressions | eerener | UNIX for Dummies Questions & Answers | 1 | 10-01-2007 12:04 AM |
| Wild card in find perm | braindrain | Shell Programming and Scripting | 1 | 04-12-2007 06:24 PM |
| ls and wild card - Should be simple! | GNMIKE | UNIX for Dummies Questions & Answers | 2 | 10-13-2005 07:41 AM |
| using if with wild card patterns | rooh | UNIX for Dummies Questions & Answers | 1 | 05-18-2002 07:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How do I pass a wild card as a variable
Hi,
I would like to pass a wild card as part of an argument. But when I do it the script views the wild card as text. Example: sFile=MG1A* sort $sFile > $sFile.sorted What I get is MG1A*.sorted The problem is I am passed a series of files where the first few characters like "MG1A" are constant. The additional part of the file name is a date time stamp. I will never know the exact date time stamp. I need to do a search for MG1A* which will find me one file. How can I write my script so the variable $sFile will know that the "*" in MG1A* is a wild card not text? I know I can write code to run "ls" on a directory and get all file names then write a loop or do statement to do my sort based upon that list regardless of the file name. But I have more files in the dir than I want to grab. I also know I can run the "ls" command output the file names in the dir to a file and grep for the part fo the file names I am looking for. I also think this can be done if I pput the whole comamnd iBut current design restricts me form going that path. It would require a whole re-write and I am trying to avoid that. Thank you. Last edited by eja; 03-28-2007 at 10:37 AM.. |
|
||||
|
Quote:
sFile='MG1A*' sort $sFile > $sFile.sorted Be sure and use single quotes - it will not expand out the wildcard at the assignment line. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|