Loading ...
Sorry, an error occurred while loading the content.

Numbering the lines of the results of terminal commands

Expand Messages
  • an_tamimi
    Hello all,, I want to ask how to numbering the lines of the results of the commands in the terminal,, e.g. numbering the results of ( ls -l ) or ( cal ) to be
    Message 1 of 18 , Dec 4, 2004
    • 0 Attachment
      Hello all,,

      I want to ask how to numbering the lines of the results of the
      commands in the terminal,,
      e.g. numbering the results of ( ls -l ) or ( cal )
      to be like the following:

      1 December 2004
      2 Su Mo Tu We Th Fr Sa
      3 1 2 3 4
      4 5 6 7 8 9 10 11
      5 12 13 14 15 16 17 18
      6 19 20 21 22 23 24 25
      7 26 27 28 29 30 31

      Thanks all
    • Godwin Stewart
      ... nl is the command you re looking for, probably. -- G. Stewart - gstewart@bonivet.net If you just try long enough and hard enough, you can always manage
      Message 2 of 18 , Dec 4, 2004
      • 0 Attachment
        On Sat, 04 Dec 2004 17:01:03 -0000, "an_tamimi" <abed@...> wrote:

        > I want to ask how to numbering the lines of the results of the
        > commands in the terminal,,

        'nl' is the command you're looking for, probably.

        --
        G. Stewart - gstewart@...

        If you just try long enough and hard enough, you can always
        manage to boot yourself in the posterior.
      • Sriram Rajan
        Hi, I use this all the time for numbering, especially when I receive compilation errors for programs. $ cal | cat -n Regards, Sriram
        Message 3 of 18 , Dec 4, 2004
        • 0 Attachment
          Hi,

          I use this all the time for numbering, especially when I receive
          compilation errors for programs.

          $ cal | cat -n

          Regards,

          Sriram
          --- In redhat@yahoogroups.com, "an_tamimi" <abed@t...> wrote:
          >
          > Hello all,,
          >
          > I want to ask how to numbering the lines of the results of the
          > commands in the terminal,,
          > e.g. numbering the results of ( ls -l ) or ( cal )
          > to be like the following:
          >
          > 1 December 2004
          > 2 Su Mo Tu We Th Fr Sa
          > 3 1 2 3 4
          > 4 5 6 7 8 9 10 11
          > 5 12 13 14 15 16 17 18
          > 6 19 20 21 22 23 24 25
          > 7 26 27 28 29 30 31
          >
          > Thanks all
        • Mohammad Sahami
          Hello all, I wrote a script, but have a problem. some files have blank in filenames and when I want to move them it issues an error. mv ~user1/$_file
          Message 4 of 18 , Dec 10, 2004
          • 0 Attachment
            Hello all,

            I wrote a script, but have a problem.

            some files have blank in filenames and when I want to move them it issues an error.

            mv ~user1/$_file ~Archive/

            for example if filename is "Racine gained control of the aljazeera", It want to move filenames Racine , gained , control , of , the and aljazeera separately while they aren't available.

            how can i sole this problem?

            Thanks,

            M. Sahami



            ---------------------------------
            Do you Yahoo!?
            Meet the all-new My Yahoo! � Try it today!

            [Non-text portions of this message have been removed]
          • Godwin Stewart
            Please don t hijack threads. Read point #2 here: http://linux.sgms-centre.com/misc/netiquette.php On Fri, 10 Dec 2004 23:12:18 -0800 (PST), Mohammad Sahami ...
            Message 5 of 18 , Dec 11, 2004
            • 0 Attachment
              Please don't hijack threads.

              Read point #2 here: http://linux.sgms-centre.com/misc/netiquette.php

              On Fri, 10 Dec 2004 23:12:18 -0800 (PST), Mohammad Sahami
              <sahami2001@...> wrote:

              > some files have blank in filenames and when I want to move them it issues
              > an error.
              >
              > mv ~user1/$_file ~Archive/

              Quote the source:

              mv "~/user1/$_file" ~Archive/

              --
              G. Stewart - gstewart@...

              BOFH excuse #237:

              Plate voltage too low on demodulator tube
            • Mohammad Sahami
              Hello all, Excuse me for mistakes. I wrote a script, but have a problem. some files have blank in filenames and when I want to move them it issues an error. mv
              Message 6 of 18 , Dec 11, 2004
              • 0 Attachment
                Hello all,

                Excuse me for mistakes.

                I wrote a script, but have a problem.

                some files have blank in filenames and when I want to move them it
                issues an error.

                mv ~user1/$_file ~Archive/

                for example if filename is "Racine gained control of the aljazeera", It
                want to move filenames Racine , gained , control , of , the and
                aljazeera separately while they aren't available.

                how can i sole this problem?

                Thanks alot,
                M. Sahami






                ---------------------------------
                Do you Yahoo!?
                Yahoo! Mail - Find what you need with new enhanced search. Learn more.

                [Non-text portions of this message have been removed]
              • Michael Schwendt
                On Sat, 11 Dec 2004 01:14:22 -0800 (PST), Mohammad Sahami ... Use double quotes: mv ~user1/$_file ~Archive/ Or properly escape every space character in the
                Message 7 of 18 , Dec 11, 2004
                • 0 Attachment
                  On Sat, 11 Dec 2004 01:14:22 -0800 (PST), Mohammad Sahami
                  <sahami2001@...> wrote:
                  >
                  >
                  > Hello all,
                  >
                  > Excuse me for mistakes.
                  >
                  > I wrote a script, but have a problem.
                  >
                  > some files have blank in filenames and when I want to move them it
                  > issues an error.
                  >
                  > mv ~user1/$_file ~Archive/
                  >
                  > for example if filename is "Racine gained control of the aljazeera", It
                  > want to move filenames Racine , gained , control , of , the and
                  > aljazeera separately while they aren't available.
                  >
                  > how can i sole this problem?

                  Use double quotes:

                  mv "~user1/$_file" ~Archive/

                  Or properly escape every space character in the file name, as in:

                  mv Racine\ gained\ control\ of\ the\ aljazeera ~Archive

                  If desired inside a script, you can modify you $_file variable, too,
                  with e.g. "sed".

                  --
                • j
                  ... From: Michael Schwendt ... as an alternative to what michael posted (see above), another way which MIGHT work (i haven t tried this
                  Message 8 of 18 , Dec 11, 2004
                  • 0 Attachment
                    ----- Original Message -----
                    From: "Michael Schwendt" <mschwendt@...>

                    > On Sat, 11 Dec 2004 01:14:22 -0800 (PST), Mohammad Sahami
                    > <sahami2001@...> wrote:
                    > >
                    > >
                    > > Hello all,
                    > >
                    > > Excuse me for mistakes.
                    > >
                    > > I wrote a script, but have a problem.
                    > >
                    > > some files have blank in filenames and when I want to move them it
                    > > issues an error.
                    > >
                    > > mv ~user1/$_file ~Archive/
                    > >
                    > > for example if filename is "Racine gained control of the aljazeera", It
                    > > want to move filenames Racine , gained , control , of , the and
                    > > aljazeera separately while they aren't available.
                    > >
                    > > how can i sole this problem?
                    >
                    > Use double quotes:
                    >
                    > mv "~user1/$_file" ~Archive/
                    >
                    > Or properly escape every space character in the file name, as in:
                    >
                    > mv Racine\ gained\ control\ of\ the\ aljazeera ~Archive
                    >
                    > If desired inside a script, you can modify you $_file variable, too,
                    > with e.g. "sed".
                    >

                    as an alternative to what michael posted (see above), another way which
                    MIGHT work (i haven't tried this yet) is to replace the spaces w/the "%20"
                    (no quotes). its not as clean/efficient as michael's suggestions, but may
                    work as well. i say "might" because i've been to web sites that have taken
                    my search parameters and they have replaced my spaces w/the %20. i
                    currently do not have linux running to check this out, but thought that i'd
                    at least mention it in case you would want to try it out.

                    j
                  • Mohammad Sahami
                    I used double quote but it does not solve it. Meanwhile i created a filename replaced instead of in this manner: _file2=`echo $_file|sed s/ //g |sed
                    Message 9 of 18 , Dec 11, 2004
                    • 0 Attachment
                      I used double quote but it does not solve it.

                      Meanwhile i created a filename replaced "\ " instead of " " in this manner:

                      _file2=`echo $_file|sed 's/\"//g'|sed 's/\ /___/g'`

                      But when script runs it issues errors.

                      Thanks

                      Michael Schwendt <mschwendt@...> wrote:
                      On Sat, 11 Dec 2004 01:14:22 -0800 (PST), Mohammad Sahami
                      <sahami2001@...> wrote:
                      >
                      >
                      > Hello all,
                      >
                      > Excuse me for mistakes.
                      >
                      > I wrote a script, but have a problem.
                      >
                      > some files have blank in filenames and when I want to move them it
                      > issues an error.
                      >
                      > mv ~user1/$_file ~Archive/
                      >
                      > for example if filename is "Racine gained control of the aljazeera", It
                      > want to move filenames Racine , gained , control , of , the and
                      > aljazeera separately while they aren't available.
                      >
                      > how can i sole this problem?

                      Use double quotes:

                      mv "~user1/$_file" ~Archive/

                      Or properly escape every space character in the file name, as in:

                      mv Racine\ gained\ control\ of\ the\ aljazeera ~Archive

                      If desired inside a script, you can modify you $_file variable, too,
                      with e.g. "sed".

                      --


                      To post to the redhat group, send your post to redhat@yahoogroups.com
                      To reach the moderators, email to redhat-owner@yahoogroups.com



                      Yahoo! Groups Sponsor
                      Get unlimited calls to

                      U.S./Canada


                      ---------------------------------
                      Yahoo! Groups Links

                      To visit your group on the web, go to:
                      http://groups.yahoo.com/group/redhat/

                      To unsubscribe from this group, send an email to:
                      redhat-unsubscribe@yahoogroups.com

                      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



                      ---------------------------------
                      Do you Yahoo!?
                      Take Yahoo! Mail with you! Get it on your mobile phone.

                      [Non-text portions of this message have been removed]
                    • Scott Robbins
                      ... Hash: SHA1 ... Try single quoting the spaces rather than doublequoting them. I ve run into this problem in my own work, a user created files on a Windows
                      Message 10 of 18 , Dec 11, 2004
                      • 0 Attachment
                        -----BEGIN PGP SIGNED MESSAGE-----
                        Hash: SHA1

                        On Sat, Dec 11, 2004 at 07:37:13AM -0800, Mohammad Sahami wrote:
                        >
                        > I used double quote but it does not solve it.
                        >
                        > Meanwhile i created a filename replaced "\ " instead of " " in this manner:
                        >
                        > _file2=`echo $_file|sed 's/\"//g'|sed 's/\ /___/g'`
                        >
                        > But when script runs it issues errors.

                        Try single quoting the spaces rather than doublequoting them. I've run
                        into this problem in my own work, a user created files on a Windows
                        machine with names like 1234.jpg and 1234 .jpg and 1234.jpg<space>

                        In the end, I was able to at least locate them with something like
                        for i in *.jpg' '; do; ls $i; done.
                        Then, I renamed them.

                        Quit netiquette note here, we (and many other Unix and Linux lists)
                        prefer that you use inline, rather than top posting. In other words,
                        answer paragraph A below paragraph A, paragraph B below paragraph B, as
                        if it were a conversation. Otherwise, anyone reading has to scroll down
                        to see what advice you have already been given. Take a look at the
                        netquette section of the list faq at
                        http://home.nyc.rr.com/computertaijutsu/linfaq.html

                        Also, of course, we prefer that you snip unnecessary things. Note that
                        I took the relevant part of your post, left that, answered you below
                        your post and then deleted the rest.

                        Anyway, hope the single quote idea helps.


                        - --

                        Scott Robbins

                        PGP keyID EB3467D6
                        ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
                        gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

                        Willow: On the other hand, maybe Rodney just stepped out
                        for a smoke.
                        Xander: For twenty-one hours?
                        Willow: It's addictive, you know.
                        -----BEGIN PGP SIGNATURE-----
                        Version: GnuPG v1.2.6 (FreeBSD)

                        iD8DBQFBuyTP+lTVdes0Z9YRAlw1AJ9x/BP29dkEiuRfqm4LsnDTsy6gRQCfaSaY
                        wTm315fl3Gl+rrFAocKHPK0=
                        =P0V+
                        -----END PGP SIGNATURE-----
                      • Godwin Stewart
                        On Sat, 11 Dec 2004 11:48:15 -0500, Scott Robbins ... Just remember that variables aren t evaluated inside single quotes. $ color= brown
                        Message 11 of 18 , Dec 11, 2004
                        • 0 Attachment
                          On Sat, 11 Dec 2004 11:48:15 -0500, Scott Robbins <scottro@...>
                          wrote:

                          > Anyway, hope the single quote idea helps.

                          Just remember that variables aren't evaluated inside single quotes.

                          $ color="brown"
                          $ echo "My hair is $color"
                          My hair is brown
                          $ echo 'My hair is $color'
                          My hair is $color

                          --
                          G. Stewart - gstewart@...

                          Any surviving best shots are ruined when someone
                          inadvertently open the darkroom door and all of the
                          dark leaks out.
                        • Scott Robbins
                          ... Hash: SHA1 ... You re quite right--I was actually using mental shorthand, which is a Bad Thing (TM). I ~meant~ single quote the spaces. Oops. ... You
                          Message 12 of 18 , Dec 11, 2004
                          • 0 Attachment
                            -----BEGIN PGP SIGNED MESSAGE-----
                            Hash: SHA1

                            On Sat, Dec 11, 2004 at 07:07:20PM +0100, Godwin Stewart wrote:
                            >
                            > On Sat, 11 Dec 2004 11:48:15 -0500, Scott Robbins <scottro@...>
                            > wrote:
                            >
                            > > Anyway, hope the single quote idea helps.
                            >
                            > Just remember that variables aren't evaluated inside single quotes.

                            You're quite right--I was actually using mental shorthand, which is a
                            Bad Thing (TM). I ~meant~ single quote the spaces.

                            Oops.


                            >
                            > $ color="brown"
                            > $ echo "My hair is $color"
                            > My hair is brown
                            > $ echo 'My hair is $color'
                            > My hair is $color

                            You color your hair? Sheesh, you're so vain. <ducks>

                            - --

                            Scott Robbins

                            PGP keyID EB3467D6
                            ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
                            gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

                            Xander: Nice. Look who's got a bad case of Dark Prince envy.
                            Dracula: I have no interest in you. Leave us.
                            Xander: No, we're not going to (imitates Dracula's accent) leave
                            you. And where'd you get that accent Sesame Street? One, two,
                            three - three victims. Mwah, ha, ha, ha!
                            Buffy: Xander, I'm pretty sure that's Dracula.
                            Xander: Wow, really? Hey, sorry, man, I was... just jokin' around.
                            -----BEGIN PGP SIGNATURE-----
                            Version: GnuPG v1.2.6 (FreeBSD)

                            iD8DBQFBu0wH+lTVdes0Z9YRAsOgAJ99Dezx2EuOU0nZSk1VOQTK5AHWOQCgr3lu
                            a3QPsWqd20hwAT1/tC6piPg=
                            =HWgV
                            -----END PGP SIGNATURE-----
                          • Godwin Stewart
                            On Sat, 11 Dec 2004 14:35:35 -0500, Scott Robbins ... Excuses excuses... Well salvaged :) ... Didn t *you* have any gray hair when you
                            Message 13 of 18 , Dec 11, 2004
                            • 0 Attachment
                              On Sat, 11 Dec 2004 14:35:35 -0500, Scott Robbins <scottro@...>
                              wrote:

                              > > Just remember that variables aren't evaluated inside single quotes.
                              >
                              > You're quite right--I was actually using mental shorthand, which is a
                              > Bad Thing (TM). I ~meant~ single quote the spaces.
                              >
                              > Oops.

                              Excuses excuses...

                              Well salvaged :)

                              > > $ color="brown"
                              > > $ echo "My hair is $color"
                              > > My hair is brown
                              > > $ echo 'My hair is $color'
                              > > My hair is $color
                              >
                              > You color your hair? Sheesh, you're so vain. <ducks>

                              Didn't *you* have any gray hair when you were pushing 40 (all those years
                              ago)? :o)

                              --
                              G. Stewart - gstewart@...

                              A fool and his money soon go partying.
                            • Scott Robbins
                              ... Hash: SHA1 ... Heh, I wish it had taken that long---after my previous marriage broke up and I then got into a completely horrendous, self-destructive
                              Message 14 of 18 , Dec 11, 2004
                              • 0 Attachment
                                -----BEGIN PGP SIGNED MESSAGE-----
                                Hash: SHA1

                                On Sat, Dec 11, 2004 at 09:07:06PM +0100, Godwin Stewart wrote:
                                >
                                > On Sat, 11 Dec 2004 14:35:35 -0500, Scott Robbins <scottro@...>
                                > wrote:
                                >
                                > > > My hair is $color
                                > >
                                > > You color your hair? Sheesh, you're so vain. <ducks>
                                >
                                > Didn't *you* have any gray hair when you were pushing 40 (all those years
                                > ago)? :o)

                                Heh, I wish it had taken that long---after my previous marriage broke up
                                and I then got into a completely horrendous, self-destructive
                                relationship, it began going grey--I was 33. :)

                                Even more years ago.



                                - --

                                Scott Robbins

                                PGP keyID EB3467D6
                                ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
                                gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

                                Spike: We're out of Wheat-a-Bix.
                                Giles: We are out of Wheat-a-Bix because you ate it all. Again.
                                Spike: Get some more.
                                Giles: I thought vampires were supposed to eat blood.
                                Spike: Yeah, well, sometimes I like to crumble up the Wheat-a-Bix
                                in the blood. Gives it a little texture.
                                Giles: Since the picture you just painted means that I will never
                                touch food of any kind again, you'll just have to pick it up
                                yourself.
                                Spike: Sissy.

                                -----BEGIN PGP SIGNATURE-----
                                Version: GnuPG v1.2.6 (FreeBSD)

                                iD8DBQFBu2UG+lTVdes0Z9YRAgWkAJ0SmENPJ4W4HQ3K+wn+jNBGvyt2XQCgjr0N
                                tXG0RoVh98ytN0agzoCMjTw=
                                =izzv
                                -----END PGP SIGNATURE-----
                              • ed
                                ... Hash: SHA1 On Sat, 11 Dec 2004 16:22:14 -0500 ... I may have only 9 years of brown/black hair left. Apparently though some females like a bald male as it
                                Message 15 of 18 , Dec 11, 2004
                                • 0 Attachment
                                  -----BEGIN PGP SIGNED MESSAGE-----
                                  Hash: SHA1

                                  On Sat, 11 Dec 2004 16:22:14 -0500
                                  Scott Robbins <scottro@...> wrote:

                                  > it began going grey--I was 33. :)

                                  I may have only 9 years of brown/black hair left. Apparently though some
                                  females like a bald male as it shows a high level of testosterone.

                                  - --
                                  /-- _| | Regards. Please note, my PGP key ID has changed.
                                  |-- / | | If you are planning on sending me something encrypted
                                  \__ \_| | please update your keyring. Debian/OpenBSD. 53C9FC6C.
                                  -----BEGIN PGP SIGNATURE-----
                                  Version: GnuPG v1.2.4 (GNU/Linux)

                                  iD8DBQFBu2vbjtZArFPJ/GwRAn9EAJ9xA4F3HlyemtVNYS+vM9llQzocPACfSX3T
                                  FRLFsYztvrtOHF2TQA+SWQQ=
                                  =3IBf
                                  -----END PGP SIGNATURE-----
                                • Godwin Stewart
                                  ... That s URL encoding and is part of the RFC related to HTTP. Nothing to do with the local filesystem. -- G. Stewart - gstewart@spamcop.net BOFH excuse #358:
                                  Message 16 of 18 , Dec 12, 2004
                                  • 0 Attachment
                                    On Sat, 11 Dec 2004 09:33:58 -0500, "j" <justo@...> wrote:

                                    > i say "might" because i've been to web sites that have taken
                                    > my search parameters and they have replaced my spaces w/the %20.

                                    That's URL encoding and is part of the RFC related to HTTP. Nothing to do
                                    with the local filesystem.

                                    --
                                    G. Stewart - gstewart@...

                                    BOFH excuse #358:

                                    struck by the Good Times virus
                                  • Michael Schwendt
                                    On Sat, 11 Dec 2004 07:37:13 -0800 (PST), Mohammad Sahami ... Why not? Rule of thumb: copy the console output to give a precise example of what behaviour you
                                    Message 17 of 18 , Dec 12, 2004
                                    • 0 Attachment
                                      On Sat, 11 Dec 2004 07:37:13 -0800 (PST), Mohammad Sahami
                                      <sahami2001@...> wrote:
                                      >
                                      > I used double quote but it does not solve it.

                                      Why not?

                                      Rule of thumb: copy the console output to give a precise example of
                                      what behaviour you see. Keep your messages short but to the point.

                                      > Meanwhile i created a filename replaced "\ " instead of " " in this manner:
                                      >
                                      > _file2=`echo $_file|sed 's/\"//g'|sed 's/\ /___/g'`
                                      >
                                      > But when script runs it issues errors.

                                      This is an incomplete example. What does the rest of the script do?
                                      What was in $_file when it failed? And why do you substitute \" with
                                      nothing?

                                      --
                                    • Cameron Simpson
                                      ... Bear in mind that ~ doesn t expand inside quotes. of course, he should be using $HOME anyway. So either: mv ~/user1/ $_file ~Archive/ or better: mv
                                      Message 18 of 18 , Dec 12, 2004
                                      • 0 Attachment
                                        On 09:24 11 Dec 2004, Godwin Stewart <gstewart@...> wrote:
                                        | On Fri, 10 Dec 2004 23:12:18 -0800 (PST), Mohammad Sahami
                                        | <sahami2001@...> wrote:
                                        | > some files have blank in filenames and when I want to move them it issues
                                        | > an error.
                                        | > mv ~user1/$_file ~Archive/
                                        |
                                        | Quote the source:
                                        | mv "~/user1/$_file" ~Archive/

                                        Bear in mind that ~ doesn't expand inside quotes. of course, he should
                                        be using $HOME anyway. So either:

                                        mv ~/user1/"$_file" ~Archive/

                                        or better:

                                        mv "$HOME/user1/$_file" ~Archive/

                                        of course then there's ~Archivo to deal with as well...

                                        Cheers,
                                        --
                                        Cameron Simpson <cs@...> DoD#743
                                        http://www.cskk.ezoshosting.com/cs/

                                        "This _is_ my day job!"
                                        - Graeme Wong See, replying to an all-too-common snide remark
                                        regarding the quality of the seamless digital sound editing on
                                        his Metallica "Enter Uodtjam" remix.
                                      Your message has been successfully submitted and would be delivered to recipients shortly.