LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-27-2011, 04:45 PM   #1
rjdelight
LQ Newbie
 
Registered: Mar 2011
Posts: 1

Rep: Reputation: 0
Trying to Sort Two Files


I have two files (passwd.txt, group.txt) that I would like to take information out of and put into a new file. I would like to list all the users having a shell “/bin/bash” followed by a space separated list of all the groups each user belongs to. I'm brand new to Linux and just trying to organize some things and learn along the way. I would also like to have the new file in alphabetical order, if that is possible.

I don't think this is that complicated of a task, but since I'm a newb I could use the help. Thanks in advance!
 
Old 03-27-2011, 05:09 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello rjdelight, welcome to LQ,

this looks like homework to me. We're not here to do your homework.

Could you please provide some information about what you've tried by yourself to solve your problem?

Markus
 
Old 03-27-2011, 06:33 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by rjdelight View Post
I have two files (passwd.txt, group.txt) that I would like to take information out of and put into a new file. I would like to list all the users having a shell “/bin/bash” followed by a space separated list of all the groups each user belongs to. I'm brand new to Linux and just trying to organize some things and learn along the way. I would also like to have the new file in alphabetical order, if that is possible.

I don't think this is that complicated of a task, but since I'm a newb I could use the help. Thanks in advance!
Two awks and a while-loop worked for me, makes a 5 line script.

Read up on "-F" in the context of awk, and on bash's while & read.



Cheers,
Tink
 
Old 03-28-2011, 08:13 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You may find these useful
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
 
Old 03-28-2011, 11:32 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
Come on Tink ... single awk is all you need ... lol
 
Old 03-29-2011, 01:06 AM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by grail View Post
Come on Tink ... single awk is all you need ... lol
True, but it loses some clarity
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sort files by size Mr. Alex Linux - Newbie 2 12-27-2010 03:46 AM
Sort files in directories based on the files date... CharlieMike73 Programming 5 09-09-2009 10:04 PM
How to sort two files then diff them? zoubidoo Linux - General 2 01-23-2009 04:42 AM
sort files teco Linux - Newbie 2 03-25-2007 04:31 PM
know how to sort files according to size marsguy Linux - General 2 04-01-2006 07:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration