Sort with field separator [duplicate]

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











up vote
-1
down vote

favorite













This question already has an answer here:



  • Two files with a common field - is it possible to sort one based on the other?

    3 answers



I'm trying to sort the /etc/passwd numerically by user id numbersb(third field) in ascending order and then send it to s4.



What command would I uses to do that? I'm on this for a while now.










share|improve this question









New contributor




Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Jeff Schaller, Goro, RalfFriedl, Thomas, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • What have you been trying? It may be useful for someone to explain not only what does work, but also why what you'd tried didn't work.
    – roaima
    2 days ago















up vote
-1
down vote

favorite













This question already has an answer here:



  • Two files with a common field - is it possible to sort one based on the other?

    3 answers



I'm trying to sort the /etc/passwd numerically by user id numbersb(third field) in ascending order and then send it to s4.



What command would I uses to do that? I'm on this for a while now.










share|improve this question









New contributor




Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Jeff Schaller, Goro, RalfFriedl, Thomas, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • What have you been trying? It may be useful for someone to explain not only what does work, but also why what you'd tried didn't work.
    – roaima
    2 days ago













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












This question already has an answer here:



  • Two files with a common field - is it possible to sort one based on the other?

    3 answers



I'm trying to sort the /etc/passwd numerically by user id numbersb(third field) in ascending order and then send it to s4.



What command would I uses to do that? I'm on this for a while now.










share|improve this question









New contributor




Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












This question already has an answer here:



  • Two files with a common field - is it possible to sort one based on the other?

    3 answers



I'm trying to sort the /etc/passwd numerically by user id numbersb(third field) in ascending order and then send it to s4.



What command would I uses to do that? I'm on this for a while now.





This question already has an answer here:



  • Two files with a common field - is it possible to sort one based on the other?

    3 answers







linux sort






share|improve this question









New contributor




Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Oct 4 at 11:00









Jeff Schaller

33.6k851113




33.6k851113






New contributor




Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Oct 4 at 10:30









Anonymous

104




104




New contributor




Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Anonymous is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by Jeff Schaller, Goro, RalfFriedl, Thomas, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Jeff Schaller, Goro, RalfFriedl, Thomas, GAD3R 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • What have you been trying? It may be useful for someone to explain not only what does work, but also why what you'd tried didn't work.
    – roaima
    2 days ago

















  • What have you been trying? It may be useful for someone to explain not only what does work, but also why what you'd tried didn't work.
    – roaima
    2 days ago
















What have you been trying? It may be useful for someone to explain not only what does work, but also why what you'd tried didn't work.
– roaima
2 days ago





What have you been trying? It may be useful for someone to explain not only what does work, but also why what you'd tried didn't work.
– roaima
2 days ago











2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Try the below code, Sort the /etc/passwd based on uid.



sort -n -t ':' -k3 /etc/passwd





share|improve this answer




















  • Thank you very much for your command. I used a different command, but I think you one will work.
    – Anonymous
    Oct 4 at 11:20

















up vote
0
down vote













There is a specific command for sorting the /etc/passwd file by UID:



# pwck -s


Just to be safe, you should use this instead of generic sort if you're sorting the actual, active /etc/passwd file for your system, as pwck will handle the necessary file locking correctly. Otherwise strange things might happen if someone attempted to log in or even query some user information while you're replacing the /etc/passwd file.






share|improve this answer



























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Try the below code, Sort the /etc/passwd based on uid.



    sort -n -t ':' -k3 /etc/passwd





    share|improve this answer




















    • Thank you very much for your command. I used a different command, but I think you one will work.
      – Anonymous
      Oct 4 at 11:20














    up vote
    1
    down vote



    accepted










    Try the below code, Sort the /etc/passwd based on uid.



    sort -n -t ':' -k3 /etc/passwd





    share|improve this answer




















    • Thank you very much for your command. I used a different command, but I think you one will work.
      – Anonymous
      Oct 4 at 11:20












    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    Try the below code, Sort the /etc/passwd based on uid.



    sort -n -t ':' -k3 /etc/passwd





    share|improve this answer












    Try the below code, Sort the /etc/passwd based on uid.



    sort -n -t ':' -k3 /etc/passwd






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Oct 4 at 10:46









    EBIN GLADSON

    3316




    3316











    • Thank you very much for your command. I used a different command, but I think you one will work.
      – Anonymous
      Oct 4 at 11:20
















    • Thank you very much for your command. I used a different command, but I think you one will work.
      – Anonymous
      Oct 4 at 11:20















    Thank you very much for your command. I used a different command, but I think you one will work.
    – Anonymous
    Oct 4 at 11:20




    Thank you very much for your command. I used a different command, but I think you one will work.
    – Anonymous
    Oct 4 at 11:20












    up vote
    0
    down vote













    There is a specific command for sorting the /etc/passwd file by UID:



    # pwck -s


    Just to be safe, you should use this instead of generic sort if you're sorting the actual, active /etc/passwd file for your system, as pwck will handle the necessary file locking correctly. Otherwise strange things might happen if someone attempted to log in or even query some user information while you're replacing the /etc/passwd file.






    share|improve this answer
























      up vote
      0
      down vote













      There is a specific command for sorting the /etc/passwd file by UID:



      # pwck -s


      Just to be safe, you should use this instead of generic sort if you're sorting the actual, active /etc/passwd file for your system, as pwck will handle the necessary file locking correctly. Otherwise strange things might happen if someone attempted to log in or even query some user information while you're replacing the /etc/passwd file.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        There is a specific command for sorting the /etc/passwd file by UID:



        # pwck -s


        Just to be safe, you should use this instead of generic sort if you're sorting the actual, active /etc/passwd file for your system, as pwck will handle the necessary file locking correctly. Otherwise strange things might happen if someone attempted to log in or even query some user information while you're replacing the /etc/passwd file.






        share|improve this answer












        There is a specific command for sorting the /etc/passwd file by UID:



        # pwck -s


        Just to be safe, you should use this instead of generic sort if you're sorting the actual, active /etc/passwd file for your system, as pwck will handle the necessary file locking correctly. Otherwise strange things might happen if someone attempted to log in or even query some user information while you're replacing the /etc/passwd file.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        telcoM

        12.2k11435




        12.2k11435












            Popular posts from this blog

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

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay