Sorting the passwd file

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Sorting the passwd file
# 1  
Old 11-28-2011
Sorting the passwd file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Sort the file /etc/passwd using the fourth field (group ID) as the primary sort, and the third field (user ID), as the secondary sort and send the output to sortedpasswd and also displaying the output on the monitor in one command line.

2. Relevant commands, code, scripts, algorithms:

sort -t: -k4,4 -k3,3 /etc/passwd

3. The attempts at a solution (include all code and scripts):

I am able to sort the file and redirect it to a new file "sortedpasswd", the problem I am running into is being able to do both. I've tried piping it through cat command and if i sort -t: -k4,4, -k3,3 > sortedpasswd, all it does is send it to a file without showing the results on the screen. Not sure how to get this done in one command line. vi or cat the results of the file would work for me, but the question appears to be doing it all in one line.

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Hagerstown Community College, Hagerstown, MD, USA Professor Trudy Gift IST-109 Introduction to Unix/Linux. This is a test question. For the record, (not sure if this excludes me from being able to ask it) All tests in this course are "take home" and using resources other than the text book, including the internet is allowed and encouraged.
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Edit: I dont understand what you mean about "link to course" I am told I cannot post a url in a thread without "5 points". However all class and instructor information is correct and verifiable to the best of my abilities and understanding.

Last edited by Nekulturny; 11-28-2011 at 04:16 AM..
# 2  
Old 11-28-2011
Solution to your 3rd question would be using
Code:
tee

command

Code:
sort -t: -k4,4, -k3,3 |tee outputfile

This User Gave Thanks to ningy For This Post:
# 3  
Old 11-28-2011
Or even:
Code:
sort -t: -k4,4, -k3,3 /etc/passwd |tee outputfile

# 4  
Old 11-28-2011
Thanks Guys! By George, it works! (Who is George anyway?)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

[solved] HP-UX /etc/passwd file

Hi. i have the accessibility to cat the /et/passwd file in this file we see the paassword field but the password is in encrypted form So, it can be possible to get the password encrypted string to convert it into human readable string via some md5 encryption code mechanism etc.. ... (6 Replies)
Discussion started by: Rajesh1091
6 Replies

2. AIX

When did AIX start using /etc/security/passwd instead of /etc/passwd to store encrypted passwords?

Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
1 Replies

3. Solaris

can't open /etc/passwd file

Hi all, Yet another problem on one of my nodes. I am unable to open my password file .It shows some junk alphabets. root@ecosdp26a>cat /etc/passwd... (10 Replies)
Discussion started by: vivek.goel.piet
10 Replies

4. UNIX for Dummies Questions & Answers

help with passwd file

Not an unix expert, I read a few pages on the web about passwd files, but I didn't find the answers I need about the last 8 lines of the passwd file I'm taking a look at. I'm assuming their shortcuts to another file that may have the actual usernames of users on the system. Please, any help... (1 Reply)
Discussion started by: fusion31
1 Replies

5. Solaris

passwd cmd reenables passwd aging in shadow entry

Hi Folks, I have Solaris 10, latest release. We have passwd aging set in /etc/defalut/passwd. I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging. When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

6. Solaris

UIDs in /etc/passwd file

Hi all, I am bit confused about UIDs on my server where LDAP athentication happens. UIDs are generally in the range of 0-65534 for any Solaris OS version(correct if i am wrong). My server is running on Solaris 9. Below are user accounts available on my server. ... (10 Replies)
Discussion started by: vvpotugunta
10 Replies

7. UNIX for Advanced & Expert Users

Recovery Of Passwd File

the file /etc/passwd has corrupted mistakenly.actually the file has saved as "oot:0:0:root:/root/sbin/bash". first r of root has been deleted .. can anyone tell me how can i recover as normal user (2 Replies)
Discussion started by: singh_hackerz
2 Replies

8. Shell Programming and Scripting

help in /etc/passwd file

Hi all, As all of us know that in /etc/passwd file the first field correspond to username could any one tell me what is bin , damoen etc in the first field, and r they in user field , what is nologin in the last column ? root:x:0:0:root:/root:/bin/bash ... (4 Replies)
Discussion started by: useless79
4 Replies

9. Cybersecurity

/etc/passwd file

hi Does anyone anyone know what the last line of a unix user passwd file signifes? Mine shows "+:::::" best (4 Replies)
Discussion started by: s_mad010
4 Replies

10. HP-UX

passwd file corrupted

Good Day Our HP box was hacked and the passwd file has been altered,there are only 2 user accounts active,and these dont have any administrative rights.I need to edit the passwd file to correct the su and root entries. Does any body have any suggestions as to how i can do this with out the root... (10 Replies)
Discussion started by: cantona7
10 Replies
Login or Register to Ask a Question