ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Bash Help

    IT Discussion
    4
    9
    734
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      Laksh1999
      last edited by Laksh1999

      I have a .txt file which is having
      title:
      ticketnumber:
      createdate:2021-08-17T00:00:00.555
      lastupdatedate:2021-08-17T05:00:00.11
      assignedgroup:

      I want to get only the date details from the ticketnumber dont need the values after T.how to do this in bash?

      cut command is working but its not showing the full data if i use it

      scottalanmillerS 1 Reply Last reply Reply Quote 0
      • scottalanmillerS
        scottalanmiller @Laksh1999
        last edited by

        @laksh1999 said in Bash Help:

        cut command is working but its not showing the full data if i use it

        If cut was working, it would show the entire result.

        Please post the cut command that you are using.

        Also, this is a cut question, not a BASH question.

        L 1 Reply Last reply Reply Quote 0
        • L
          Laksh1999 @scottalanmiller
          last edited by Laksh1999

          @scottalanmiller said in Bash Help:

          @laksh1999 said in Bash Help:

          cut command is working but its not showing the full data if i use it

          If cut was working, it would show the entire result.

          Please post the cut command that you are using.

          Also, this is a cut question, not a BASH question.

          title:Test Ticket how are you
          ticketnumber:D000000000
          createdate:2021-08-17T00:00:00.555
          lastupdatedate:2021-08-17T05:00:00.11
          assignedgroup:Group

          I am in need to cut only the createdate and lastupdatedate only .How to do this ?

          cut -b 1-23 data.txt
          
          1 1 Reply Last reply Reply Quote 0
          • 1
            1337 @Laksh1999
            last edited by 1337

            @laksh1999 said in Bash Help:

            @scottalanmiller said in Bash Help:

            @laksh1999 said in Bash Help:

            cut command is working but its not showing the full data if i use it

            If cut was working, it would show the entire result.

            Please post the cut command that you are using.

            Also, this is a cut question, not a BASH question.

            title:Test Ticket how are you
            ticketnumber:D000000000
            createdate:2021-08-17T00:00:00.555
            lastupdatedate:2021-08-17T05:00:00.11
            assignedgroup:Group

            I am in need to cut only the createdate and lastupdatedate only .How to do this ?

            cut -b 1-23 data.txt
            

            There are much better ways than trying to do string manipulation with bash and small utilities.

            I suggest any scripting language that you might be familiar with, for instance perl, php, python etc. It's easy to do what you want with any programming language.

            Bash and utilities such as awk, sed, grep, cut etc are excellent for simple, quick and dirty hacks. But when you want to extract data from files and perhaps reformat it, it's much easier to do it with a more suitable tool. Perl in fact was made by a sysadmin for this specific purpose.

            JaredBuschJ 1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch @1337
              last edited by

              @pete-s his source data is json

              1 1 Reply Last reply Reply Quote 0
              • 1
                1337 @JaredBusch
                last edited by

                @jaredbusch said in Bash Help:

                @pete-s his source data is json

                So even more reason to use a scripting language then.

                Both php and python can read and write json files natively. It looks like perl needs to have a module installed.

                L 1 Reply Last reply Reply Quote 0
                • L
                  Laksh1999 @1337
                  last edited by Laksh1999

                  @pete-s said in Bash Help:

                  @jaredbusch said in Bash Help:

                  @pete-s his source data is json

                  So even more reason to use a scripting language then.

                  Both php and python can read and write json files natively. It looks like perl needs to have a module installed.

                  Since there is a restriction installing modules in my developer desktop so only trying without python

                  1 1 Reply Last reply Reply Quote 0
                  • 1
                    1337 @Laksh1999
                    last edited by 1337

                    @laksh1999 said in Bash Help:

                    @pete-s said in Bash Help:

                    @jaredbusch said in Bash Help:

                    @pete-s his source data is json

                    So even more reason to use a scripting language then.

                    Both php and python can read and write json files natively. It looks like perl needs to have a module installed.

                    Since there is a restriction installing modules in my developer desktop so only trying without python

                    I understand but using bash and small utilities is like trying to perform surgery with a hacksaw.

                    I'd look into getting the right tools installed on your desktop before wasting more time on trying to come up with some inflexible bash script.

                    My personal preference is actually php. A lot of people think it's just for web development and don't realize it's actually a script language that you could use for anything.

                    scottalanmillerS 1 Reply Last reply Reply Quote 0
                    • scottalanmillerS
                      scottalanmiller @1337
                      last edited by

                      @pete-s said in Bash Help:

                      My personal preference is actually php. A lot of people think it's just for web development and don't realize it's actually a script language that you could use for anything.

                      Rarely use it for that specifically, but PHP is definitely an awesome general purpose scripting language. I especially like that it is so good for web and great as a gp scripting language. So you get the best of one and one of the best of the other.

                      I like Python a lot, too. And it covers the same range of things as PHP. But I like PHP better.

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post