This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using dos2unix and attaching it to a while loop


I am dealing with DOS text files and need to output DOS text files. This scenario is not about
converting a file in DOS format to UNIX format; or read a file line by line. It relates to using
Unix commands and manipulating a dos file and staying in a dos format

How do you read each line in a while loop? 
Do I need to change the IFS or use dos2unix? 
How does a Bash script output a DOS text file?

I found dos2unix, but I do not know how to properly implement it. The following Bash code is a
work-in- progress. Please let me know if a more efficient approach exists. 

while read line
	do
		i=0
		echo "LINE -> $line"
		echo "i -> $i"
		MP3[i++]=$(awk '/^.*\.mp3/ { print $1}')
		CRC[i++]=$(awk '/^.*\.mp3/ { print $3}')
		echo "MP3[i] -> $MP3[i]"
		echo "CRC[i] -> $CRC[i]"
	done < <(dos2unix "$FILE")

 #do some stuff  then
unix2dos "$FILE"

The cygwin console returns the following error. My syntax is not correct. 

FileRenamer3.sh: line 132: syntax error near unexpected token `<'
FileRenamer3.sh: line 132: `          done < <
(dos2unix "$FILE")'


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]