Skip to main content

Normalize line-endings examples with sed.

#!/bin/sh

# For DOS to Unix: 
sed s/.$// infilename >outfilename 

#For Mac to Unix: 
sed s/x0d/x0a/ infilename >outfilename 

# For Unix to DOS: 
sed s/$/x0d/ infilename >outfilename

# For Unix to Mac: 
sed s/x0a/x0d/ infilename >outfilename

# For DOS to Mac: 
sed s/x0d// infilename >outfilename

# For Mac to DOS: 
sed s/x0a/x0dx0a/ infilename >outfilename