Date: Thu, 10 Jan 2002 19:15:38 -0800 From: chip <chip@wiegand.org> To: Ken Bolingbroke <hacker@bolingbroke.com> Cc: questions@FreeBSD.ORG Subject: Re: txt file from ls -la? Message-ID: <200201101914844.SM01552@there> In-Reply-To: <20020110165555.A5440-100000@fremont.bolingbroke.com> References: <20020110165555.A5440-100000@fremont.bolingbroke.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 10 January 2002 05:12 pm, Ken Bolingbroke banged out on the k= eys: > On Thu, 10 Jan 2002, chip wrote: > > I would like to create a file I can import into mysql that consists o= f > > the names and sizes of all the files in a directory. The files are > > images. I tried ls -la > images.txt, expecting to get all the info fr= om > > ls -la, but that gave me the file names only. I could just type them = all > > into the database but there are apr. 2500 files, so the file import w= ould > > be much easier. How can I get the names and sizes only into a text fi= le? > > Something like this would do the job: > > cd /image/directory/ > ls -l | awk '{print $9 "\t" $5}' > /tmp/images.txt > > That would give you a tab delimited file with the filenames in the firs= t > column and the file sizes in the second column. > > Ken Bolingbroke > hacker@bolingbroke.com That's cool, and works perfectly. I had to read up on awk to find out wha= t=20 that little script was doing. I figured it out too, $9 is the ninth field= =20 (file name) and $5 is the fifth field (size) when running ls -l, and the = \t=20 is a tab. Shoot, that's really quite easy, guess I might just buy an awk = book=20 now and learn a bit about it. Thanks, --=20 Chip www.wiegand.org <+><+><+><+><+><+><+><+> Windows 95/NT - 32 bit extensions and a graphical shell for a 16 bit patc= h to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company that can't stand 1 bit of competition. <+><+><+><+><+><+><+><+> To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201101914844.SM01552>