mersenneforum.org Fedora gedit for bash has become useless
 Register FAQ Search Today's Posts Mark Forums Read

 2016-05-11, 02:55 #1 EdH     "Ed Hall" Dec 2009 Adirondack Mtns 23·3·5·31 Posts Fedora gedit for bash has become useless [rant] The more Fedora advances, the more useless it is becoming - recall my other issues... Now I find that gedit is producing a "Windows" formatted text, that won't run as a bash script. Do any of the learned linux guys have a quick fix? I'm about to trash Fedora. Maybe it's past time... [/rant] Thanks for any help... Last fiddled with by EdH on 2016-05-11 at 02:55
 2016-05-11, 04:03 #2 Mark Rose     "/X\(‘-‘)/X\" Jan 2013 3×977 Posts Check the line ending setting. You want "Unix" line termination, not "Windows" or "Mac". I don't use gedit personally, as I really dislike Gnome, but googling tells me there should be a "Line Ending" setting when you save the file.
 2016-05-11, 13:10 #3 jasonp Tribal Bullet     Oct 2004 2·29·61 Posts Your system should also have 'unix2dos' and 'dos2unix' utilities that allow you to retroactively fix the line endings on files you have. Windows notepad similarly cannot properly display files with unix line endings; I work around as necessary. Incompatibilities between text editors are low on the list of cross-platform problems that I have to deal with.
 2016-05-11, 13:29 #4 EdH     "Ed Hall" Dec 2009 Adirondack Mtns 23·3·5·31 Posts Thank you for the replies. I had looked with no success for the line ending setting. It must be hiding with the un/redo entries I'm suppose to have. Anyway, the problem is fixed. I unwittingly caused it due to another recent shortfall of Fedora: files no longer allows for the creation of a new document via a right-click. Therefore, I copied/pasted an existing .sh file and edited it. Apparently the c/p transformed the original's line endings for some unknown reason. By starting afresh with a new gedit document, and creating/saving a .sh file with the proper first line, the line endings are correct for the rest of the editing. I was unaware of the two conversion routines. Thanks! I may make use of those.
 2016-05-11, 15:22 #5 Xyzzy     "Mike" Aug 2002 8,167 Posts Attached Thumbnails
 2016-05-11, 15:28 #6 Xyzzy     "Mike" Aug 2002 8,167 Posts For fun you can use od to view the actual contents of a file. Code: $cat dos.txt | od -c 0000000 a b c 1 2 3 \r \n 1 2 3 a b c \r \n 0000020$ cat unix.txt | od -c 0000000 a b c 1 2 3 \n 1 2 3 a b c \n 0000016 More info: http://stackoverflow.com/questions/2...in-bash-script
2016-05-11, 15:31   #7
Xyzzy

"Mike"
Aug 2002

11111111001112 Posts

Quote:
 Originally Posted by jasonp Windows notepad similarly cannot properly display files with unix line endings; I work around as necessary.
Open the file in "Wordpad" first, then just save it and then open it in "Notepad".

2016-05-11, 15:40   #8
ccorn

Apr 2010

2×3×52 Posts

Quote:
 Originally Posted by jasonp Windows notepad similarly cannot properly display files with unix line endings; I work around as necessary. Incompatibilities between text editors are low on the list of cross-platform problems that I have to deal with.
Funnily enough, the "edit" command in the DOS box ("run command...") can deal with unix line endings; just opening and saving the text file should convert the line endings to CR LF. At least that was in XP times, and I do not use Windows much. Of course, notepad++ can handle such things too.
Quote:
 Originally Posted by EdH Now I find that gedit is producing a "Windows" formatted text, that won't run as a bash script. Do any of the learned linux guys have a quick fix?
With standard coreutils, from dos to unix (delete CR):
Code:
tr -d '\r' <winfile.txt >unixfile.txt
or in-place with sed (and with a backup file):
Code:
sed -i.bak 's:\r::g' textfile.txt

 2016-05-13, 06:55 #9 LaurV Romulan Interpreter     Jun 2011 Thailand 22·17·139 Posts in windoze, use Programmers' Notepad ! (one of the best, small, and free!) (no, eclipse is not "small") You can select what line endings you want, and write your own scripts, own menu commands, etc, if you like. It also has a nice python extension and lots of syntax schema...
 2016-05-13, 13:08 #10 Mark Rose     "/X\(‘-‘)/X\" Jan 2013 3×977 Posts Notepad. I remember using Notepad. Once I had to create a web based tutorial on using FrontPage. FrontPage was so awful I wrote the tutorial in Notepad.
2016-05-13, 15:03   #11
rogue

"Mark"
Apr 2003
Between here and the

2×7×11×41 Posts

Quote:
 Originally Posted by Xyzzy Open the file in "Wordpad" first, then just save it and then open it in "Notepad".

 Similar Threads Thread Thread Starter Forum Replies Last Post jasong Forum Feedback 1050 2019-04-29 00:50 Dubslow Information & Answers 11 2011-12-14 21:07 jasong GMP-ECM 8 2011-01-03 03:57 lycorn PrimeNet 16 2009-09-08 18:16 tha Software 2 2004-01-13 23:12

All times are UTC. The time now is 10:12.

Mon May 17 10:12:05 UTC 2021 up 39 days, 4:52, 0 users, load averages: 1.39, 1.45, 1.43