Date: Tue, 17 Aug 2010 17:09:39 -0400 (EDT) From: vogelke+unix@pobox.com (Karl Vogel) To: freebsd-questions@freebsd.org Subject: Re: Bash Script Help - File Names With Spaces Message-ID: <20100817210939.B7FFFBF39@kev.msw.wpafb.af.mil> In-Reply-To: message from Drew Tomlinson on Tue, 17 Aug 2010 07:47:25 -0700
next in thread | raw e-mail | index | archive | help
>> On Tue, 17 Aug 2010 07:47:25 -0700,
>> Drew Tomlinson <drew@mykitchentable.net> said:
D> Then I attempt to use 'basename' to extract the file name to a variable
D> which I can later pass to 'ln'. This seems to work:
D> basename "/archive/Multimedia/Audio/Music/Billboard Top USA
D> Singles/1980-028 Kenny Loggins - This Is It.mp3"
This is a subset of a larger problem: getting the last field from a set
of delimited records which may not all have the same number of fields.
I've used this when I needed basenames for ~500,000 files:
find . regex-or-print-or-whatever | rev | cut -f1 -d/ | rev
For dirnames:
find . regex-or-print-or-whatever | rev | cut -f2- -d/ | rev | sort -u
--
Karl Vogel I don't speak for the USAF or my company
When I'm feeling down, I like to whistle. It makes the
neighbor's dog run to the end of his chain and gag himself. --unknown
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100817210939.B7FFFBF39>
