Re: regexp
From: Stephane CHAZELAS (this.address_at_is.invalid)
Date: 10/31/03
- Next message: Kumar Sundaram: "Re: regexp"
- Previous message: John-Paul Stewart: "Re: Setting The System Clock [Linux]"
- Next in thread: Kumar Sundaram: "Re: regexp"
- Maybe reply: Kumar Sundaram: "Re: regexp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 31 Oct 2003 19:46:40 +0100
2003/10/31, 10:46(-06), Kumar Sundaram:
> How do a get a regexp to match the data given below in a find statement. I
> use a * at the end and it maches a number or nothing.
>
> for script in `find /home/xxx -name "send[a-d][a-z][a-z]*" -print`
> do
> echo "$script"
> nohup $script &
> echo "$script executed"
> done
I'm not sure to understand your question. Does this somehow
answer your question:
find /home/xxx -type f -perm -111 \( \
-name 'send[a-d][a-z][a-z]' -o \
-name 'send[a-d][a-z][a-z][0-9]' \) -exec sh -c '
printf %s\\n "$1"
nohup "$1" &
printf "%s started in background\n" "$1"' {} {} \;
-name argument is not a regexp but a wildcard, see man fnmatch
for how to use wildcards.
-perm 111
is a check to see if the file is executable. Note that it just
checks wether everyone has execute permission for it. That's an
approximation. Better solution could be:
find /home/xxx -type f -perm +111 \( \
-name 'send[a-d][a-z][a-z]' -o \
-name 'send[a-d][a-z][a-z][0-9]' \) -exec sh -c '
[ -x "$1" ] || exit 1
printf %s\\n "$1"
nohup "$1" &
printf "%s started in background\n" "$1"' {} {} \;
Unfortunately, find has not option to check if *you* (the user
running find) have the right to execute a given file.
-- Stéphane ["Stephane.Chazelas" at "free.fr"]
- Next message: Kumar Sundaram: "Re: regexp"
- Previous message: John-Paul Stewart: "Re: Setting The System Clock [Linux]"
- Next in thread: Kumar Sundaram: "Re: regexp"
- Maybe reply: Kumar Sundaram: "Re: regexp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|