Page 1 of 1

Windows edit of bash file fix

Posted: 07 Jan 2023, 16:47
by Ed_P
If a .sh file is edited in Windows it becomes non-executable in Linux due to a carriage return at the end of lines. Bogomips had a command that fixed the problem, does anyone remember it or have a link to his posting?

Windows edit of bash file fix

Posted: 07 Jan 2023, 18:19
by babam
dos2unix

Windows edit of bash file fix

Posted: 07 Jan 2023, 19:49
by Ed_P
Thanks babam I will check it out. :)

I thought Bogomips thing was a bash command with grep and sed functions.

Windows edit of bash file fix

Posted: 08 Jan 2023, 01:26
by Rapha_
I see this as "Alternatives to dos2unix conversion" :
Unix2dos

Code: Select all

$ tr -d '\r' < file > file2
or

Code: Select all

$ perl -i -p -e 's/\r//g' file
or

Code: Select all

$ sed -i -e 's/\r//g' file
or

Code: Select all

$ col -b < InFile > OutFile

Windows edit of bash file fix

Posted: 08 Jan 2023, 05:21
by Ed_P
Thanks Rapha_. :)

I getmoded dos2unix and I found Bogomips post: Re: [INFO & SCRIPT] Slackware Mirror Settings for USM (Post by Bogomips #56484) which is similar to your tr one. I'll play around with the various options and see which one is the easiest for me to use.

Thanks guys. :beer: