[Cialug] shell escaping with command substitution?

Todd E Thomas todd.dsm at gmail.com
Tue Feb 10 17:52:55 CST 2015


Do you have a github repo or a pastebin somewhere for a more in-depth
visual of what you are starting with and where you wold like to end up?

I like these problems, I can take a look at it and describe the how's and
whys; things like 'cat <(./testpgm)' might work but just seeing it makes me
feel weird.

Also, don't forget your double-quotes; as Pixie pointed out, you never know
when a space will preset itself:
"$(command)"

--
Thanks in advance,

Todd E Thomas
C: 515.778.6913

*"It's a frail music knits the world together."-Robert Dana*


On Tue, Feb 10, 2015 at 9:01 AM, Daniel A. Ramaley <daniel.ramaley at drake.edu
> wrote:

> Does testpgm output 1 long line of single-quoted filenames? I'm asking
> this seemingly silly question because i'm not sure what e-mail wrapping
> may have done to your command output.
>
> If it is possible to modify testpgm, then it might be easier to have
> testpgm output one filename per line, without the quotes. Then you can
> process the files with a while loop:
>     ./testpgm | while read FILE ; do cat "${FILE}" ; done
> As someone else posted, you might also be able to use xargs; the while
> loop here is more typing but can be useful for other situations such as
> if you want to run multiple commands on each file instead of just a
> simple "cat".
>
> On 2015-02-09 at 21:41:14 Kenneth Younger wrote:
> > Alright, a basics question, because apparently my shell-fu isn't
> > strong enough to figure this out:
> >
> > I have a command I wrote, testpgm. When ./testpgm is run it outputs
> > this:
> >
> > '/Users/kenny/test/test 3.txt' '/Users/kenny/test/test1.txt'
> > '/Users/kenny/test/test2.txt'
> >
> > When I then run cat $(./testpgm), I get errors. If I copy and paste
> > the output instead of doing command substitution, it works fine. What
> > gives? This is the error:
> >
> > cat: '/Users/kenny/test/test: No such file or directory
> > cat: 3.txt': No such file or directory
> > cat: '/Users/kenny/test/test1.txt': No such file or directory
> > cat: '/Users/kenny/test/test2.txt': No such file or directory
> >
> > It almost seems like it's double-escaping the output of testpgm.
> >
> > Thanks in advance for any insights.
> >
> > -Kenny
> __
> Daniel A. Ramaley  |  Network Engineer 2
> Drake Technology Services (DTS) | Drake University
>
> T: +1 515 271-4540
> F: +1 515 271-1938
> E: daniel.ramaley at drake.edu
>
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>


More information about the Cialug mailing list