2009/9/19 Daniel Bush <dlb.id...@gmail.com> > > > 2009/9/19 Aleksey Tsalolikhin <atsaloli.t...@gmail.com> > >> On Fri, Sep 18, 2009 at 6:42 AM, Daniel Bush <dlb.id...@gmail.com> wrote: >> > Hi, >> > Writing a little utility to help me on something but having trouble. >> > Why does f stay blank? >> > >> > d...@lin4:test$ echo "foo|bar" | awk 'BEGIN{RS="|"}{ print $1 }' | >> while >> > read s; do echo $s; f=$s; done; echo "'$f'" >> > foo >> > bar >> > '' >> >> and >> >> > The string being piped is an extended regular expression which I wanted >> to >> > prepend with a file path >> >> You mean, like this? >> >> # echo "foo|bar" | awk 'BEGIN{RS="|"}{ print "filepath/"$1 }' >> filepath/foo >> filepath/bar >> # >> >> If that's not it, could you give an example of the desired output? >> >> > More like this: > > rprepend() { > ruby <<-EOF > f='$1'.split('|').collect{|i|i.chomp.sub(/^/,'$RSUBDIR.*')}.join('|'); > puts f; > EOF > } > > d...@lin4:image_library$ RSUBDIR='/path' > d...@lin4:image_library$ rprepend 'foo|bar' > /path.*foo|/path.*bar > > It's a long story and it's not an application, it's part of a larger cli > utility to help me find and grep filenames and their contents in a project > and some of its nested subprojects so I can think and work that much faster > without having to pause and move around groping for the right file (from the > shell). > > Thanks everyone for helping. > > -- > Daniel Bush > > > oh crap, before anyone beats me to it; yes I could have done it this way:
echo 'foo|bar'|sed -e 's#^#/path.*#;s#|#|path.*#;' -- Daniel Bush -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html