[GLLUG] why doesn't this work?

Mike Rambo mrambo at lsd.k12.mi.us
Fri Oct 24 12:45:16 EDT 2003


On Thu, 2003-10-23 at 21:57, Bong Munoz wrote:
> Marshal Newrock wrote:
> > On Thu, 23 Oct 2003, Mike Rambo wrote:
> > 
> > 
> >>I'm trying to combine the text of all files in a directory into one
> >>large file with the one liner:
> >>
> >>for TARGET in `ls | awk {'print $9'}`; do cat $TARGET >> makeAll.mysql;
> >>done;
> > 
> > That is indeed puzzling.  I can think of two possible things: 1) that the
> > files are symlinks to other files, which are missing, or 2) that the
> > filenames contain non-printable characters.  See what 'ls -lQ' says.
> 
> Mike, why not omit awk from the one-liner: for target in `ls -1`; do cat 
> $target >>makeall.mysql; done?
> 
> "ls -1" returns the one filename per line so you can omit awk.  I tried 
> it this way and I can concatenate all files into a single file.  Even 
> shorter is the standard: cat *.mysql >>makeall.mysql.
> 
> --bong
> 

Well, no. ls -l returns one line but there is much more than just the
filename on it.

-rw-rw-r--    1 mrambo   mrambo        838 Jan  1  2003 building.mysql

cat then tries to put content from several things (like permissions,
owner, date, all the stuff in the white space separated list) into the
big file - which does include an attempt at the desired content that is
still unsuccessful.

The shorter method of course (and probably the one Sean mentioned
elsewhere) does work. I thought of that on the way home yesterday but
I'm still perplexed about why the one I tried doesn't because it looks
to me like it should. I'd like to understand why it doesn't if anyone
can figure it out.


-- 
Mike Rambo
mrambo at lsd.k12.mi.us

NOTE: In order to control energy costs the light at the end 
of the tunnel has been shut off until further notice...



More information about the linux-user mailing list