我們有一個名爲LineFeed.sh
的shell腳本文件,它具有將換行符(LF
)轉換爲回車+換行符的功能。我們希望通過Windows中的批處理文件完成相同的操作。可能嗎?批處理文件+將LF轉換爲CR + LF
的Linux shell文件
E_WRONGARGS=65
cat OutputList|while read -r Line
do
if [ -z "$Line" ]
then
echo "Usage: `basename $0` filename-to-convert"
exit $E_WRONGARGS
fi
NEWFILENAME=$Line.unx
CR='\015' # Carriage return.
# 015 is octal ASCII code for CR.
# Lines in a DOS text file end in CR-LF.
# Lines in a UNIX text file end in LF only.
tr -d $CR < $1 > $NEWFILENAME // here its deleting CR but i need to append LF
# Delete CR's and write to new file.
done
echo "Original DOS text file is \"$1\"."
echo "Converted UNIX text file is \"$NEWFILENAME\"."
exit 0
http://www.google.com/search?q=unix2dos.bat – Heinzi 2010-06-24 12:50:16
@Heinzi:http://meta.stackexchange.com/questions/5280/embrace-the-non-googlers – Joey 2010-06-24 18:15:47
@Johannes:其實,我的評論不只是谷歌的問題,但包含一個答案。是的,我過於簡潔。詳細版本可能是:「你自己不需要這樣做;有一個名爲unix2dos的腳本,它完全符合你的要求,並且有可用的Windows端口,通常稱爲」unix2dos.bat「。如果你是谷歌關鍵字,你會發現很多來源下載它。「 (不過,我確實明白你的觀點,感謝你的鏈接。) – Heinzi 2010-06-24 20:49:44