BASH scripting question
From: NS (lesborock_at_NOSPAM.yahoo.com.au)
Date: Tue, 07 Oct 2003 14:33:39 +1000
I have a very simple task that eludes me.
I have been in the process of administrating a huge amount of data on a
pre-existing file server. The problem is that a lot of the directories and
files have been copied from various sources and as a result have
non-sequitor file names. eg. containing one or more spaces and ampersands.
This obviously causes some problems.
Stop me here if there is an easier way.
I need to compile a list of all these files and especially directories.
So in a shell script I do:
directories=`find . -type d -print`
The problem is that the escape characters for the spaces etc. get
interpereted as newlines, so that when I try to reference the names from
within the variable it breaks them.
I have tried (and other variations):
echo $directories | sed -e 's/\\//g' > result
directories =`cat result`
but still no joy.
I know it's simple but I can't seem to work it out.
Thanks in advance.