From: RensFunHog on
How can I exclude a fileName within a For Do script?

for x in A.log B.txt NOT C.log

do
<<taskHERE>>

done


I am scanning a single directory and if the fileName has string
'someName' I want to exclude it from the For statement.

Thanks...
From: Ed Morton on
On Jan 20, 11:44 am, RensFunHog <pbars...(a)gmail.com> wrote:
> How can I exclude a fileName within a For Do script?
>
> for x in A.log B.txt NOT C.log
>
> do
> <<taskHERE>>
>
> done
>
> I am scanning a single directory and if the fileName has string
> 'someName' I want to exclude it from the For statement.
>
> Thanks...

Assuming "has" means "includes" rather than "is":

case $x in
*someName* )
# skip it
;;
* ) ...do what you want...
;;
esac

In general, though, if you're writing a shell loop to do something
other than work with processes or create/move/remove files you're
probably on the wrong track.

Ed.
From: Barry Margolin on
In article
<440aa6aa-9b70-44cc-a4cf-5fd29f6978d4(a)p8g2000yqb.googlegroups.com>,
RensFunHog <pbarstad(a)gmail.com> wrote:

> How can I exclude a fileName within a For Do script?
>
> for x in A.log B.txt NOT C.log
>
> do
> <<taskHERE>>
>
> done
>
>
> I am scanning a single directory and if the fileName has string
> 'someName' I want to exclude it from the For statement.
>
> Thanks...

for x in *.log *.txt
do
case "$x" in
*someName*) ;;
*) <<taskHERE>> ;;
esac

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Janis Papanagnou on
RensFunHog wrote:
> How can I exclude a fileName within a For Do script?

If you're using Kornshell...

for x in !(C.log)
do
:
done


Janis

>
> for x in A.log B.txt NOT C.log
>
> do
> <<taskHERE>>
>
> done
>
>
> I am scanning a single directory and if the fileName has string
> 'someName' I want to exclude it from the For statement.
>
> Thanks...
From: Seebs on
On 2010-01-20, RensFunHog <pbarstad(a)gmail.com> wrote:
> How can I exclude a fileName within a For Do script?
>
> for x in A.log B.txt NOT C.log
>
> do
><<taskHERE>>
>
> done
>
>
> I am scanning a single directory and if the fileName has string
> 'someName' I want to exclude it from the For statement.

No, you don't. You want to exclude it from task.

case $x in
*someName*) continue;;
esac

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!