Awk to get all my regular users in shadowConvey some message to all usersHow can I process multi-line records...

Can a Hogwarts student refuse the Sorting Hat's decision?

How to prevent Deadlock on SELECT queries?

What is the difference between "un plan" and "une carte" (in the context of map)?

foot-pounds of energy?

Are valid inequalities worth the effort given modern solver preprocessing options?

Would this winged human/angel be able to fly?

Did Logical Positivism fail because it simply denied human emotion?

Is a text with orthographic or grammatic mistakes in a language X still a text in that language X?

What printing process is this?

The Game of the Century - why didn't Byrne take the rook after he forked Fischer?

How easy is it to get a gun illegally in the United States?

How do I show and not tell a backstory?

A verb for when some rights are not violated?

When using the Proficiency Dice optional rule, how should they be used in determining a character's Spell Save DC?

How to make clear to my boyfriend that I simply don't have anything to talk about

Glue-up for butcher block-style countertop

How to win against ants

Properties: Left of the colon

A Checkmate of Dubious Legality

Need reasons why a satellite network would not work

Is a switch from R to Python worth it?

Is the first page of a novel really that important?

Is it uncompelling to continue the story with lower stakes?

Is it okay to use different fingers every time while playing a song on keyboard? Is it considered a bad practice?



Awk to get all my regular users in shadow


Convey some message to all usersHow can I process multi-line records with awk in a bash script?return value from awkUpstart - unable to read /etc/shadow unless sudoBash: Regular Expressions in substitutionSet expire date for usersGet one element of path string using bashSeparating Commands in a Script File?Substitute cut command inside AWK scriptMake variables show a column with awk






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







5















I have a script.



I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.



My pattern is



sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'


It doesn't work for now.










share|improve this question



























  • does it have to be awk? :-)

    – Rinzwind
    10 hours ago


















5















I have a script.



I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.



My pattern is



sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'


It doesn't work for now.










share|improve this question



























  • does it have to be awk? :-)

    – Rinzwind
    10 hours ago














5












5








5








I have a script.



I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.



My pattern is



sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'


It doesn't work for now.










share|improve this question
















I have a script.



I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.



My pattern is



sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'


It doesn't work for now.







bash scripts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 10 hours ago









Eliah Kagan

87.7k22 gold badges243 silver badges386 bronze badges




87.7k22 gold badges243 silver badges386 bronze badges










asked 10 hours ago









danasodanaso

675 bronze badges




675 bronze badges
















  • does it have to be awk? :-)

    – Rinzwind
    10 hours ago



















  • does it have to be awk? :-)

    – Rinzwind
    10 hours ago

















does it have to be awk? :-)

– Rinzwind
10 hours ago





does it have to be awk? :-)

– Rinzwind
10 hours ago










2 Answers
2






active

oldest

votes


















8














You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".



sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~  /^!$/ {print $1}'





share|improve this answer




























  • +1 good catch :)

    – Rinzwind
    10 hours ago











  • Thanks, it works. I just need to not include root user

    – danaso
    10 hours ago











  • Simplified: awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"

    – Dennis Williamson
    27 mins ago



















3














All users with a password set can be listed like this:



getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:





share|improve this answer




























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1163551%2fawk-to-get-all-my-regular-users-in-shadow%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    8














    You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".



    sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~  /^!$/ {print $1}'





    share|improve this answer




























    • +1 good catch :)

      – Rinzwind
      10 hours ago











    • Thanks, it works. I just need to not include root user

      – danaso
      10 hours ago











    • Simplified: awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"

      – Dennis Williamson
      27 mins ago
















    8














    You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".



    sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~  /^!$/ {print $1}'





    share|improve this answer




























    • +1 good catch :)

      – Rinzwind
      10 hours ago











    • Thanks, it works. I just need to not include root user

      – danaso
      10 hours ago











    • Simplified: awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"

      – Dennis Williamson
      27 mins ago














    8












    8








    8







    You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".



    sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~  /^!$/ {print $1}'





    share|improve this answer















    You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".



    sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~  /^!$/ {print $1}'






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 10 hours ago

























    answered 10 hours ago









    pLumopLumo

    10.5k21 silver badges48 bronze badges




    10.5k21 silver badges48 bronze badges
















    • +1 good catch :)

      – Rinzwind
      10 hours ago











    • Thanks, it works. I just need to not include root user

      – danaso
      10 hours ago











    • Simplified: awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"

      – Dennis Williamson
      27 mins ago



















    • +1 good catch :)

      – Rinzwind
      10 hours ago











    • Thanks, it works. I just need to not include root user

      – danaso
      10 hours ago











    • Simplified: awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"

      – Dennis Williamson
      27 mins ago

















    +1 good catch :)

    – Rinzwind
    10 hours ago





    +1 good catch :)

    – Rinzwind
    10 hours ago













    Thanks, it works. I just need to not include root user

    – danaso
    10 hours ago





    Thanks, it works. I just need to not include root user

    – danaso
    10 hours ago













    Simplified: awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"

    – Dennis Williamson
    27 mins ago





    Simplified: awk -F: '$2 ~ /^!?$/ {print $1}' - This combines the two match tests and says "match a dollar sign at the beginning of the field, optionally (?) preceded by a !"

    – Dennis Williamson
    27 mins ago













    3














    All users with a password set can be listed like this:



    getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:





    share|improve this answer






























      3














      All users with a password set can be listed like this:



      getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:





      share|improve this answer




























        3












        3








        3







        All users with a password set can be listed like this:



        getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:





        share|improve this answer













        All users with a password set can be listed like this:



        getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 10 hours ago









        RinzwindRinzwind

        220k29 gold badges425 silver badges567 bronze badges




        220k29 gold badges425 silver badges567 bronze badges

































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1163551%2fawk-to-get-all-my-regular-users-in-shadow%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

            The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

            Ayherre Geografie Demografie Externe links Navigatiemenu43° 23′ NB, 1° 15′ WL43° 23′ NB, 1°...