I want to create a file for each hash code, with the .txt extension.
I ran a test shell script called test1.sh to see if I could pull out each line in the file and create a file name from it:
#!/bin/sh
while read line
do
echo $line.txt
done < hashlist.txt
echo "done"
What I got was
$ ./test1.sh | less
185ead08e45a5cbb51e9f7b0b384aaa2^M.txt
57643e1a17252a9fc746d49c3da04168^M.txt
60cba11d09221d52aaabb5db30f408a2^M.txt
2b75ee6e5c2efc31b4ee9a190d09a4df^M.txt
...... etc.
How can I create these file names without the ^M?
It seems if I remove the ^M and replace it with a carriage return (/r) then the while loop won't work.
Convert the file first using dos2unix or dos2ux utility, if you can't find it (would be surprised though...) I will give you some alternatives (scripts?).
After conversion you should not have any trouble...
P.S.
Next time, use code tags for your code and data
If you imported your file from MS win... world , you have the reasom of the presence of these char on end of line...(thoufh some clever ftp utilities do the conversion for you...)
Or remove the extra characters with "tr" as you read the file.
#!/bin/sh
cat hashlist.txt | tr -d '\r' | while read line
do
echo "${line}.txt"
done
echo "done"
As I'm sure you realise, the spurious carriage-return is Microsoft Text File format. How you transfer a file to a unix platform is important (e.g. use text mode ftp not binary mode ftp).