Windows edit of bash file fix

Technical issues/questions of an intermediate or advanced nature.
User avatar
Ed_P
Contributor
Contributor
Posts: 8369
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Windows edit of bash file fix

Post#1 by Ed_P » 07 Jan 2023, 16:47

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?
Ed

User avatar
babam
Warlord
Warlord
Posts: 528
Joined: 16 Nov 2016, 10:30
Distribution: Porteus 5.0rc3 Xfce K6.1.1
Location: Rainy city

Windows edit of bash file fix

Post#2 by babam » 07 Jan 2023, 18:19

dos2unix
Sorry, my English is bad.

User avatar
Ed_P
Contributor
Contributor
Posts: 8369
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Windows edit of bash file fix

Post#3 by Ed_P » 07 Jan 2023, 19:49

Thanks babam I will check it out. :)

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

Rapha_
Shogun
Shogun
Posts: 238
Joined: 12 Jun 2021, 21:59
Distribution: Xfce 4.12 - 5.rc3 - x86_64
Location: France

Windows edit of bash file fix

Post#4 by Rapha_ » 08 Jan 2023, 01:26

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

User avatar
Ed_P
Contributor
Contributor
Posts: 8369
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Windows edit of bash file fix

Post#5 by Ed_P » 08 Jan 2023, 05:21

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:
Ed

Post Reply