From owner-freebsd-questions Thu Jan 10 19:13:33 2002 Delivered-To: freebsd-questions@freebsd.org Received: from pioneernet.net (mail.pioneernet.net [207.115.64.224]) by hub.freebsd.org (Postfix) with ESMTP id DEE0337B400 for ; Thu, 10 Jan 2002 19:13:30 -0800 (PST) Received: from there [66.114.152.128] by pioneernet.net (SMTPD32-6.06) id A89337880056; Thu, 10 Jan 2002 19:14:27 -0800 Content-Type: text/plain; charset="iso-8859-1" From: chip To: Ken Bolingbroke Subject: Re: txt file from ls -la? Date: Thu, 10 Jan 2002 19:15:38 -0800 X-Mailer: KMail [version 1.3.2] Cc: questions@FreeBSD.ORG References: <20020110165555.A5440-100000@fremont.bolingbroke.com> In-Reply-To: <20020110165555.A5440-100000@fremont.bolingbroke.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200201101914844.SM01552@there> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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