mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Linux

Reply
 
Thread Tools
Old 2016-05-11, 02:55   #1
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

334510 Posts
Default 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
EdH is offline   Reply With Quote
Old 2016-05-11, 04:03   #2
Mark Rose
 
Mark Rose's Avatar
 
"/X\(‘-‘)/X\"
Jan 2013

2×1,427 Posts
Default

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.
Mark Rose is offline   Reply With Quote
Old 2016-05-11, 13:10   #3
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

3,529 Posts
Default

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.
jasonp is offline   Reply With Quote
Old 2016-05-11, 13:29   #4
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

3×5×223 Posts
Default

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.
EdH is offline   Reply With Quote
Old 2016-05-11, 15:22   #5
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

7,691 Posts
Default

Attached Thumbnails
Click image for larger version

Name:	gedit.png
Views:	94
Size:	93.7 KB
ID:	14349  
Xyzzy is offline   Reply With Quote
Old 2016-05-11, 15:28   #6
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

1E0B16 Posts
Default

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
Xyzzy is offline   Reply With Quote
Old 2016-05-11, 15:31   #7
Xyzzy
 
Xyzzy's Avatar
 
"Mike"
Aug 2002

7,691 Posts
Default

Quote:
Originally Posted by jasonp View Post
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".

Xyzzy is offline   Reply With Quote
Old 2016-05-11, 15:40   #8
ccorn
 
ccorn's Avatar
 
Apr 2010

3×72 Posts
Default

Quote:
Originally Posted by jasonp View Post
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 View Post
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
ccorn is offline   Reply With Quote
Old 2016-05-13, 06:55   #9
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

221E16 Posts
Default

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...
LaurV is offline   Reply With Quote
Old 2016-05-13, 13:08   #10
Mark Rose
 
Mark Rose's Avatar
 
"/X\(‘-‘)/X\"
Jan 2013

2·1,427 Posts
Default

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.
Mark Rose is offline   Reply With Quote
Old 2016-05-13, 15:03   #11
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

22·52·59 Posts
Default

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

Try NotePad++. It blows away NotePad on all fronts.
rogue is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Posts that seem less than useless, or something like that jasong Forum Feedback 1050 2019-04-29 00:50
bash and HTTP? Dubslow Information & Answers 11 2011-12-14 21:07
Fedora ecm installed, but where? jasong GMP-ECM 8 2011-01-03 03:57
Useless DC assignment lycorn PrimeNet 16 2009-09-08 18:16
Fedora tha Software 2 2004-01-13 23:12

All times are UTC. The time now is 04:00.

Mon Sep 21 04:00:47 UTC 2020 up 11 days, 1:11, 0 users, load averages: 1.40, 1.32, 1.33

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.