/mnt/hda6/Directory2
...
In a shell script I want to read this file line by line and depending on the type of entry, directory or file, I want to take some action. Because file and directory names may contain spaces, I cannot do it like this:
ENTRY=$(cat input_file)
for I in $ENTRY
do
...
done
I found a solution for this:
LINES=$(wc -l input_file)
while [ $LINES -gt 0 ]
do
ENTRY=$(sed -e '1q' input_file)
#do smth
sed -e '2,$w input_file' input_file
LINES=$(wc -l input_file)
done
By this I memorise the first line and delete the first line from input_file. But I don't like this solution because it writes the file each time in the loop. Could suggest anyone a more elegant solution.