Reading a file using sh with spaces in filename

Hi

I am trouble parsing through a file with spaces in the filename. I need to grab "supportIDPS/SCM/windows_install/file groups/dds.fgl" and then do a md5sum on it. I am using sh.
Any help is appreciated.

Here is an example of the input file:
7eedbc9f7902bf4c1878d9e571addf9a supportIDPS/SCM/windows_install/file groups/dds.fgl
341001e442a16435a4dca02ce0fb1fa6 supportIDPS/SCM/windows_install/file groups/default.fdf
a06707d4ff14b9718ad1a876689ae3ad supportIDPS/SCM/windows_install/file groups/inf.fgl

Try the cut command.

With a space as fieldseperator you can print the 2nd and the 3th column. Check the manpage of cut.

Regards

As told by Franklin52, you can use:

cut -f2- -d ' ' input_file

I figured out two solutions:

Solution 1:
while read line ;do
CUT=`echo "$line" | sed 's/^.* //g'`
md5sum $CUT
done < INFPUT_FILE

Solution 2:
while read checksum file ;do
md5sum "$file"
done < INPUT_FILE

Thanks everyone

Try searching for my posts - I gave some instructions about this.
But in short way:

USE:
"${variable}"
instead of
$variable

1 Like