Grep only gids from /etc/passwd

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I want to grep only group IDs from /etc/passwd. Now I only came up how to grep the names, with:



grep -oE '^[^:]+' /etc/passwd


which gives me:



[frynio@manjaro ~]$ grep -oE '^[^:]+' /etc/passwd
root
nobody
dbus
bin
daemon
mail
ftp
http
systemd-journal-remote
systemd-coredump
uuidd
dnsmasq
rpc
usbmux
avahi
colord
cups
deluge
git
lightdm
nm-openconnect
nm-openvpn
ntp
polkitd
frynio


How can I change this regex, to omit the first three :s and then start matching with [^:]+? (cuz the ^ before it matches the beginning of the line, that's why I can extract the names, and I want something to match the position after 3 colons)









share

























    up vote
    0
    down vote

    favorite












    I want to grep only group IDs from /etc/passwd. Now I only came up how to grep the names, with:



    grep -oE '^[^:]+' /etc/passwd


    which gives me:



    [frynio@manjaro ~]$ grep -oE '^[^:]+' /etc/passwd
    root
    nobody
    dbus
    bin
    daemon
    mail
    ftp
    http
    systemd-journal-remote
    systemd-coredump
    uuidd
    dnsmasq
    rpc
    usbmux
    avahi
    colord
    cups
    deluge
    git
    lightdm
    nm-openconnect
    nm-openvpn
    ntp
    polkitd
    frynio


    How can I change this regex, to omit the first three :s and then start matching with [^:]+? (cuz the ^ before it matches the beginning of the line, that's why I can extract the names, and I want something to match the position after 3 colons)









    share























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I want to grep only group IDs from /etc/passwd. Now I only came up how to grep the names, with:



      grep -oE '^[^:]+' /etc/passwd


      which gives me:



      [frynio@manjaro ~]$ grep -oE '^[^:]+' /etc/passwd
      root
      nobody
      dbus
      bin
      daemon
      mail
      ftp
      http
      systemd-journal-remote
      systemd-coredump
      uuidd
      dnsmasq
      rpc
      usbmux
      avahi
      colord
      cups
      deluge
      git
      lightdm
      nm-openconnect
      nm-openvpn
      ntp
      polkitd
      frynio


      How can I change this regex, to omit the first three :s and then start matching with [^:]+? (cuz the ^ before it matches the beginning of the line, that's why I can extract the names, and I want something to match the position after 3 colons)









      share













      I want to grep only group IDs from /etc/passwd. Now I only came up how to grep the names, with:



      grep -oE '^[^:]+' /etc/passwd


      which gives me:



      [frynio@manjaro ~]$ grep -oE '^[^:]+' /etc/passwd
      root
      nobody
      dbus
      bin
      daemon
      mail
      ftp
      http
      systemd-journal-remote
      systemd-coredump
      uuidd
      dnsmasq
      rpc
      usbmux
      avahi
      colord
      cups
      deluge
      git
      lightdm
      nm-openconnect
      nm-openvpn
      ntp
      polkitd
      frynio


      How can I change this regex, to omit the first three :s and then start matching with [^:]+? (cuz the ^ before it matches the beginning of the line, that's why I can extract the names, and I want something to match the position after 3 colons)







      linux grep





      share












      share










      share



      share










      asked 4 mins ago









      Frynio

      1273




      1273

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478296%2fgrep-only-gids-from-etc-passwd%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f478296%2fgrep-only-gids-from-etc-passwd%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?