Search This Blog

Monday, March 7, 2011

Searching trick for the Linux less tool

Event after so many year of working on the command line I constantly find some trick ;). This is one of them for the less tool.

With the syntax bellow the less will do a normal search like using the '/' char, but will look for the 2th occurrence of our regex expression and once found will jump to it immediately to display.

$ man tune2fs | less -R  +2/-U -X
      -U UUID
              Set   the   universally   unique   identifier   (UUID)   of   the  filesystem  to  UUID.   The  format  of  the  UUID  is  a  series  of  hex  digits  separated  by  hyphens,  like  this:
              "c1b9d5a2-f162-11cf-9ece-0020afc76f16".  The UUID parameter may also be one of the following:

                   clear  clear the filesystem UUID

                   random generate a new randomly-generated UUID

                   time   generate a new time-based UUID

              The UUID may be used by mount(8), fsck(8), and /etc/fstab(5) (and possibly others) by specifying UUID=uuid instead of a block special device name like /dev/hda1.

              See uuidgen(8) for more information.  If the system does not have a good random number generator such as /dev/random or /dev/urandom, tune2fs will  automatically  use  a  time-based  UUID
              instead of a randomly-generated UUID.

The source of it can be found on the FAQ page of the less itself: Less FAQ

No comments:

Post a Comment