![]() |
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 |
| regular expression help | Bob565656 | Shell Programming and Scripting | 6 | 09-09-2008 02:32 PM |
| regular expression | ag79 | Shell Programming and Scripting | 3 | 03-19-2008 07:10 AM |
| awk and regular expression | maskot | Shell Programming and Scripting | 4 | 05-22-2007 07:22 AM |
| help in regular expression | Rakesh Ranjan | High Level Programming | 5 | 10-25-2006 01:00 PM |
| Regular Expression + Aritmetical Expression | Z0mby | Shell Programming and Scripting | 2 | 05-21-2002 10:59 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Regular Expression on Directory Contents
This should be an easy question for you gurus.
![]() How can I create a regular expression to match all files in the current directory that have only one period in their file name, and also not contain the string "abc" before the period? It would match: foo.txt foobar.log It would not match: foo.bar.txt abc.txt I'm going to use this inside an if-statement in a ksh script, if that makes any difference. |
|
||||
|
That works wonderfully, thanks! In case anyone cares, here's the final code (with private details omitted), once put inside a for-loop and if-statement. Maybe not the best way, but it works...
Code:
for file in *; do
if [[ `echo $file | awk -F\. 'NF==2 && !/abc\./' | wc -l` -ge 1 ]]; then
#do something
fi
done
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|