export last numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • quartz
    New Member
    • Aug 2007
    • 19

    export last numbers

    If I have a files, e.g;

    gff.t00z.pgrbf2 1
    gff.t00z.pgrbf2 4
    ...
    gff.t00z.pgrbf4 5


    How can I now, what command to use to inform me about last two digits,
    21, 24,...45??

    Thanks
  • diSangro
    New Member
    • Jan 2007
    • 69

    #2
    Originally posted by quartz
    If I have a files, e.g;

    gff.t00z.pgrbf2 1
    gff.t00z.pgrbf2 4
    ...
    gff.t00z.pgrbf4 5


    How can I now, what command to use to inform me about last two digits,
    21, 24,...45??

    Thanks
    Using csh , if your file is called mytxt.txt , you can use :

    Code:
    cat mytxt.txt | awk-F"grbf" '{print $2}'
    your output is:
    21
    24
    ..
    45

    it can be sent to a file through redirection ( > )

    Comment

    • quartz
      New Member
      • Aug 2007
      • 19

      #3
      The problems is that :
      gff.t00z.pgrbf2 1
      gff.t00z.pgrbf2 4
      ...
      gff.t00z.pgrbf4 5

      are binary files and about 35 Mb, just named like that.

      Any solutions,
      Thanks

      Comment

      • diSangro
        New Member
        • Jan 2007
        • 69

        #4
        In other words you have to create a list of all these filenames, put this list into a file (mytxt.txt) then you can use the command mentioned on post #2 .

        To create such a list, assuming all these files are placed in one folder and that "gff" is contained in each filename:

        go inside that folder and create mytxt.txt with the following command:

        Code:
        ls | grep gff > mytxt.txt
        Then use the command mentioned on post #2.
        Does it help?


        Originally posted by quartz
        The problems is that :
        gff.t00z.pgrbf2 1
        gff.t00z.pgrbf2 4
        ...
        gff.t00z.pgrbf4 5

        are binary files and about 35 Mb, just named like that.

        Any solutions,
        Thanks

        Comment

        • Nepomuk
          Recognized Expert Specialist
          • Aug 2007
          • 3111

          #5
          Originally posted by diSangro
          In other words you have to create a list of all these filenames, put this list into a file (mytxt.txt) then you can use the command mentioned on post #2...
          Shouldn't it be possible, to do all of this without an external file? I was thinking of something like this:
          Code:
          ls gff.t00z.pgrbf* | awk-F"grbf" '{print $2}'
          Greetings,
          Nepomuk

          Comment

          • diSangro
            New Member
            • Jan 2007
            • 69

            #6
            Of course it's possible !
            It's just...At the beginning I thought all was already into a file!!!



            Originally posted by nepomuk
            Shouldn't it be possible, to do all of this without an external file? I was thinking of something like this:
            Code:
            ls gff.t00z.pgrbf* | awk-F"grbf" '{print $2}'
            Greetings,
            Nepomuk

            Comment

            • Nepomuk
              Recognized Expert Specialist
              • Aug 2007
              • 3111

              #7
              Originally posted by diSangro
              Of course it's possible !
              It's just...At the beginning I thought all was already into a file!!!
              No Problem. ^^
              So, the final code you're looking for is:
              Code:
              ls gff.t00z.pgrbf* | awk -F"grbf" '{print $2}'
              Thanks diSangro, I learnt something too! ^^

              Greetings,
              Nepomuk

              Comment

              • radoulov
                New Member
                • Jun 2007
                • 34

                #8
                With zsh;

                Code:
                print *(:s/gff.t00z.pgrbf/)

                with bash/ksh93:

                Code:
                set -- gff.t00z.pgrbf*
                echo ${@//gff.t00z.pgrbf}

                Comment

                • quartz
                  New Member
                  • Aug 2007
                  • 19

                  #9
                  Hi,

                  All of these possibilities working perfectly.

                  Thanks a lot!!

                  Comment

                  Working...