[Gambas-user] OT: BASH help!
Hamish Robertson
robertsonhamish at ...626...
Mon May 12 06:24:07 CEST 2008
You're a champion! thank you so much! One last question...how do I pipe the
output into a variable(String) to be used in the control file? I'm guessing
the perl script here will be the easiest. If I can get a variable that will
work in my bash script I'm away! :)
Thanks so much.
H.
2008/5/12 Rob <sourceforge-raindog2 at ...94...>:
> On Sunday 11 May 2008 21:48, Hamish Robertson wrote:
> > Yeah I've tried that ls thingy but I need to get rid or the .deb
> > extension and list it as csv...i.e package1, package2, package3,
> > etc...
> >
> > is this do-able in bash? or is something like perl or python the go
> > here?
>
> Here's how to remove file extensions and convert a list to a
> comma-separated line, in bash:
>
> /bin/ls *.deb | xargs -ix echo `basename x` | tr "\n" ","; echo
>
> That will end the line with a comma, though, and there's no space
> after each comma. Using perl (you can paste this into a bash script,
> no need to write the whole thing in perl):
>
> perl -e 'print join(", ", map { s/.deb$//; $_ } split("\n", `ls
> *.deb`)), "\n";'
>
> That produces a normal comma-separated list terminated by a newline.
> You can also use sed and awk to do this, but my skills in those have
> atrophied in the decade since I started using perl.
>
> > Can I do it in gambas?
>
> Sure.... haven't tried to compile this, but here's the general idea:
>
> dim f as new string[]
> dim d as string
> f = dir(".", "*.deb")
> for each d in f
> d = left(d, length(d) - 4)
> next
> print f.join(", ")
>
> That should produce the same result as the perl one-liner.
>
> Rob
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
>
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list