Bash Script Help - File Names With Spaces
Karl Vogel
vogelke+unix at pobox.com
Tue Aug 17 21:29:38 UTC 2010
>> On Tue, 17 Aug 2010 07:47:25 -0700,
>> Drew Tomlinson <drew at 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
More information about the freebsd-questions
mailing list