Showing posts with label line breaks. Show all posts
Showing posts with label line breaks. Show all posts

Monday, September 21, 2015

DOS and UNIX line breaks

Here are my scripts 2unix and 2dos, which convert a given text file to one with guaranteed UNIX line breaks or guaranteed DOS line breaks:


#!/bin/sh
# script 2unix
# AOF 14-6-2-05
# make $1 have LF line breaks
# remove all CR:
sed -i 's/\r//' $1
echo $1 now has only LF \(UNIX\) line breaks.
echo \(To view them use cat -e $1.\)



#!/bin/sh
# script 2dos
#AOF 14-6-2-15
# make $1 have CRLF line breaks
# first remove all CR:
sed -i 's/\r//' $1
# then add CR before each LF:
sed -i 's/$/\r/' $1
echo $1 now has only CRLF \(DOS\) line breaks.
echo To view them use cat -e $1.