Announcement

Collapse
No announcement yet.

BASH help please.....

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Originally posted by MoonRise View Post
    ... Truthfully I'd never have thought that as I can't actually see the EOL. Is there a way in Kate to make the EOL visible?
    I couldn't find one.

    Regards, John Little
    Regards, John Little

    Comment


      #17
      Kate is Windows/DOS 'aware'.

      End of Line – There is a big and irritating difference between the way that Windows-based programs and Linux programs deal with line endings in text files. The standard text file line ending in Windows is two special characters, a carriage return followed by a line feed, while in Linux it’s one special character, a line feed alone. This can cause major problems when text files created in one OS are opened in the other. Most Linux-based text editing programs recognise this and provide an option to convert to Windows conventions when saving the file. Kate has also provided this option under Tools as a separate command – plus an additional option for the Macintosh.

      I believe that when Kate opens a text file created in Windows/DOS, those two special characters are preserved. To convert them to the Linux single character line feed, you need to go to Tools > End of Line and ensure that UNIX is selected. This is easy enough to confirm. Check that Kate is configured for UNIX End of Line. Open a Windows/DOS text file (that hasn't been played with in Linux). Check Tools > End of Line. My bet is it will show Windows/DOS.
      Using Kubuntu Linux since March 23, 2007
      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

      Comment


        #18
        I'll test that out and see.

        Comment


          #19
          I occasionally use Geany (a great little program editor/IDE) rather than Kate sometimes. It makes developing and testing script files a breeze. Geany has an option to show the EOL character(s).

          The setting is View, Editor, Show Line Endings in Geany.
          Attached Files
          Desktop PC: Intel Core-i5-4670 3.40Ghz, 16Gb Crucial ram, Asus H97-Plus MB, 128Gb Crucial SSD + 2Tb Seagate Barracuda 7200.14 HDD running Kubuntu 18.04 LTS and Kubuntu 14.04 LTS (on SSD).
          Laptop: HP EliteBook 8460p Core-i5-2540M, 4Gb ram, Transcend 120Gb SSD, currently running Deepin 15.8 and Manjaro KDE 18.

          Comment


            #20
            I just noticed that Geany actually shows the EOL mode in the status line too.
            Desktop PC: Intel Core-i5-4670 3.40Ghz, 16Gb Crucial ram, Asus H97-Plus MB, 128Gb Crucial SSD + 2Tb Seagate Barracuda 7200.14 HDD running Kubuntu 18.04 LTS and Kubuntu 14.04 LTS (on SSD).
            Laptop: HP EliteBook 8460p Core-i5-2540M, 4Gb ram, Transcend 120Gb SSD, currently running Deepin 15.8 and Manjaro KDE 18.

            Comment


              #21
              Originally posted by Snowhog View Post
              ...To convert them to the Linux single character line feed, you need to go to Tools > End of Line and ensure that UNIX is selected. This is easy enough to confirm. Check that Kate is configured for UNIX End of Line. Open a Windows/DOS text file (that hasn't been played with in Linux). Check Tools > End of Line. My bet is it will show Windows/DOS.
              So, a kate user has to click Tools and mouse over End of Line to become aware that the file has the problematic characters. If the idea had not occurred to the user, such as the OP, they'd have no reason to do so. I envisage something on the status line, beside or with the encoding; though a prominent warning for some file types would be appropriate.

              I did discover that if one turns off Settings | Configure Kate | Editor Component | Open/Save | General tab | Automatic end of line detection, and Tools | End of Line is set to UNIX, kate will silently read a file with DOS line endings, and save it with UNIX ones if you make changes to it. That would be dangerous if one works with files that brain damaged windows software needs to read; I've encountered XML like that. Thankfully, most windows apps are happy with unixy newlines.

              I've just had a hunt around the Kate documentation and discovered lots about it's scripting with javascript, but they're limited to "indenting" and "command line" scripts; there isn't a hook to run a script after loading a file (though I did write a "command" that set line-endings to unix) and the API is quite limited, I couldn't find any access to the UI.

              Regards, John Little
              Regards, John Little

              Comment


                #22
                Originally posted by Rod J View Post
                I occasionally use Geany (a great little program editor/IDE) rather than Kate sometimes. It makes developing and testing script files a breeze. Geany has an option to show the EOL character(s).

                The setting is View, Editor, Show Line Endings in Geany.
                I'll take a look at that. That may be useful. Thanks!


                @JL --- Thanks for the info. Keep that in mind too since I do have to go between the two OSs.

                Comment


                  #23
                  Originally posted by MoonRise View Post
                  Code:
                  myDATE=`date '+%m%d%Y'`
                  myTIME=`date '+%H%M%S'`
                  One other tip. Backticks are deprecated. Instead, use command substitution. The advantage is that you don't have to escape any dollar signs, backticks, or back slashes inside the command.
                  Code:
                  myDATE=$(date '+%m%d%Y')
                  myTIME=$(date '+%H%M%S')
                  Also, for sorting purposes, you might consider the ISO date format of year-month-day instead:
                  Code:
                  myDATE=$(date '+%Y%m%d')

                  Comment


                    #24
                    Originally posted by SteveRiley View Post
                    One other tip. Backticks are deprecated. Instead, use command substitution. The advantage is that you don't have to escape any dollar signs, backticks, or back slashes inside the command.
                    And nesting is easier. Basically the only reason you'd want to use backticks is that there is a chance your script is run in a real bourne shell...modern linux distributions usually symlink /bin/sh to a more modern shell (ash, dash or bash), so this usually isn't an issue.

                    Comment


                      #25
                      I usually do use the ISO format for sorting purposes but the way this is really used wasn't necessary and the user who gets this generared file is use to a system of ours that displays as I have here. In all my readings I did run across the two formats for the command but it was never clear one over the other so I'll keep that in mind.

                      Comment

                      Working...
                      X