A Question on output parsing

A Question on output parsing

Post by Trik » Thu, 07 Nov 2002 08:40:09



Here is the idea I am going for:
I want to run the command

 find / -name target.file -print

and parse ONLY the path not the path with the file name appended.

  I know there must be a simple way of doing this, but it has me stumped at
the moment

I am using ksh on SCO UNIX.  The issue here is portability., All systems are
SCO but the output of the find can vary greatly (Directory depth various on
the systems I work on)  If I could assign this find command to a varible and
loop it to take a prescribed action with in the directory of the targetted
file, It would be the last peice to a HUGE puzzle I have been struggling
with for quiet some time!

 Thanks...

 
 
 

A Question on output parsing

Post by Chris F.A. Johnso » Thu, 07 Nov 2002 08:47:00



> Here is the idea I am going for:
> I want to run the command

>  find / -name target.file -print

> and parse ONLY the path not the path with the file name appended.

>   I know there must be a simple way of doing this, but it has me stumped at
> the moment

> I am using ksh on SCO UNIX.  The issue here is portability., All systems are
> SCO but the output of the find can vary greatly (Directory depth various on
> the systems I work on)  If I could assign this find command to a varible and
> loop it to take a prescribed action with in the directory of the targetted
> file, It would be the last peice to a HUGE puzzle I have been struggling
> with for quiet some time!

      find / -name target.file -print |
           while read file
           do
              dir=${file%/*}
           done

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

A Question on output parsing

Post by Kevin Rodger » Thu, 07 Nov 2002 09:29:23



> Here is the idea I am going for:
> I want to run the command

>  find / -name target.file -print

> and parse ONLY the path not the path with the file name appended.

>   I know there must be a simple way of doing this, but it has me stumped at
> the moment

How about:

find / -type d -print |
while read dir
do
   [[ -e $dir/target.file ]] || continue
   # Act on $dir here
done

Quote:> I am using ksh on SCO UNIX.  The issue here is portability., All systems are
> SCO but the output of the find can vary greatly (Directory depth various on
> the systems I work on)  If I could assign this find command to a varible and
> loop it to take a prescribed action with in the directory of the targetted
> file, It would be the last peice to a HUGE puzzle I have been struggling
> with for quiet some time!

--
<a href="mailto:&lt;kevinr&#64;ihs.com&gt;">Kevin Rodgers</a>
 
 
 

A Question on output parsing

Post by Robert Lip » Thu, 07 Nov 2002 15:00:59



> Here is the idea I am going for:
> I want to run the command

>  find / -name target.file -print

> and parse ONLY the path not the path with the file name appended.

 find . -name target.file -exec dirname {} \;
 
 
 

1. lk-changelog.pl now to parse bk changes - output

Hi,

I released lk-changelog.pl v0.26, my changelog reformatter, which does
parse the "bk changes" output format (this was reported by Marcelo
Tosatti) and not only the format of the BK-kernel-tools/changelog script
(which Linus uses).

I'm not pasting my program this time, as the next version is supposed to
pull the log out of bitkeeper itself.

Find v0.26 at http://mandree.home.pages.de/linux/kernel/

--
Matthias Andree
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. Solaris/Novell Integration

3. parsing ps -ax output and killing processes

4. Adding Hard Disk.

5. parse html output

6. How do I create libraries?

7. parsing the output of a php-page with a xml-handler like cocoon

8. is the wd8013 driver broken in 2.0.2{6,7}?

9. tcpdump output parsing

10. gdthd: Cannot parse output

11. newbie: parsing 'cut -n' output

12. CGI outputting text/x-server-parsed-html?

13. Any way to parse SSI of Apache CGI or module output?