Re: printf question

2013-02-12 Thread Greg Wooledge
On Tue, Feb 12, 2013 at 04:20:53AM -0800, laurent.tes...@gmail.com wrote:
> > liste=`ls *.T02`

This is broken because filenames may contain spaces, newlines, etc.
Use an array instead:

liste=(*.T02)

See http://mywiki.wooledge.org/BashPitfalls for an explanation of some
of the issues.

This type of question is more appropriate for the help-bash mailing list,
by the way.

> 1> teqc.exe `ls *.T02` > out.T02
> 2> teqc.exe  $liste> out.T02
> 3> teqc.exe "$liste"   > out.T02

All of those are wrong, each in its own way.

> What is the proper way of doing this ?

Well, the easiest way would be:

teqc.exe *.T02 > out.T02

If you insist on storing the filenames in advance for some reason, use
an array:

files=(*.T02)
teqc.exe "${files[@]}" > out.T02

If you run into command line length issues, then you may have to process
the array in several chunks.  See http://mywiki.wooledge.org/BashFAQ/095
for examples of that.



printf question

2013-02-12 Thread laurent . testut
Dear All,
  I need to run a command that concat a list of files. It work like cat in UNIX.

 teqc.exe file1 file2 ... > output 

  Then I want to build this list of file with bash, and insert it in a shell 
script. 

> liste=`ls *.T02`
> echo $liste
SHOB087k.T02 SHOB087l.T02 SHOB087m.T02 SHOB087n.T02 SHOB087o.T02 SHOB087p.T02 
SHOB087q.T02 SHOB087r.T02 SHOB087s.T02 SHOB087t.T02 SHOB087u.T02 SHOB087v.T02 
SHOB087w.T02 SHOB087x.T02 SHOB088a.T02 SHOB088b.T02 SHOB088c.T02 SHOB088d.T02 
SHOB088e.T02 SHOB088f.T02 SHOB088g.T02 SHOB088h.T02 SHOB088i.T02 SHOB088j.T02 
SHOB088k.T02 SHOB088l.T02 SHOB088m.T02 SHOB088n.T02 SHOB088o.T02 SHOB088p.T02 
SHOB088q.T02

Echo gives me the list files I want (although the first 4 letter are in 
UPPERCASE which is not the case of the real list?), in a row format, but printf 
doesn't work the same way and I don't understant why.

> printf $liste
> SHOB087k.T02

return the first element (in uppercase format ???)

> printf "$liste"
> SHOB087k.T02
SHOB087l.T02
SHOB087m.T02
SHOB087n.T02
.
.

return the list element in column format ??

What shouls I put i my shell 

1> teqc.exe `ls *.T02` > out.T02
2> teqc.exe  $liste> out.T02
3> teqc.exe "$liste"   > out.T02

What is the proper way of doing this ?

Thanks for your help 

Regards,
Laurent