[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Bug in my shell script
- From: "Pete Peterson" <petersonp genrad com>
- To: jjans bio vu nl, guinness-list redhat com
- Subject: Re: Bug in my shell script
- Date: Fri, 30 Mar 2001 07:22:14 -0500 (EST)
> From guinness-list-admin@redhat.com Thu Mar 29 15:16:13 2001
> Delivered-To: guinness-list@listman.redhat.com
> From: "Jasper Jans" <jjans@bio.vu.nl>
> To: <guinness-list@redhat.com>
> Subject: Bug in my shell script
>
> Hi..
>
> I'm trying to write a shell script but for some reason I cannot
> get it to work.. can anyone be so good to tell me what is going
> wrong here?
>
> ---
> #!/bin/sh -x
>
> if [ $# -eq 0 ]; then
> echo "Usage: $0 <expression>";
> exit;
> fi
>
> echo "find /home/guests/jjans -type d -name '*"$1"*' -exec 'sed s/*.sts//g'
> \;" | sh
I think you just want:
find /home/guests/jjans -type d -name \*$1\* -print | sed 's%/^home/guests%%'
You don't really need the -print, since that's a default, but I usually
include it out of habit.
You don't need the "g" on the sed pattern in this case, since there
would only be one match per line.
I think it's better to be more specific in the pattern match -- there
could be an "sts" somewhere farther along in the line and then you'd
zap everything before that. Consider:
/home/guests/jjans/Projects/A/costs/estimates
With just looking for "sts", you'd end up with
/estimates
instead of
/jjans/Projects/A/costs/estimates
The "^" in the pattern also helps avoid 'surprises'.
Note that I piped the output of 'find' into 'sed'. It appears that
your way would try to run sed on the directory itself, rather than
on the list of names. I suspect that sed wouldn't like that.
> ---
>
> I call this like: ./bla.sh roje
> And the find part (if I run that seperately) returns lines like:
> /home/guests/jjans/Projects/A
> /home/guests/jjans/Projects/B
> etc..
>
> The sed part is support to strip of the /home/guests part and make it
> such that the output is
> /jjans/Projects/A
> /jjans/Projects/B
> etc..
>
> However when I run this I get absolutely no output at all..
> Anyone?
>
> Thanks,
> J.
pete peterson
GenRad, Inc.
7 Technology Park Drive
Westford, MA 01886-0033
petersonp@genrad.com or rep@genrad.com
+1-978-589-7478 (GenRad); +1-978-256-5829 (Home: Chelmsford, MA)
+1-978-589-2088 (Closest FAX); +1-978-589-7007 (Main GenRad FAX)
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]