The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Changing root group to group from other mjkroner SUN Solaris 4 03-05-2009 04:25 AM
retrieving all group names with a given group number Andrewkl UNIX for Advanced & Expert Users 3 10-25-2008 05:07 AM
Sort cmd to get GROUP BY? RacerX UNIX for Dummies Questions & Answers 6 10-16-2008 08:40 AM
Monkcast #12: IBM HW group OEMs Solaris to chagrin of SW group & a ... - ZDNet.com bl iBot UNIX and Linux RSS News 0 08-17-2007 05:30 PM
entry in /etc/group too long - problem using sudo with %group poli SUN Solaris 4 12-21-2004 09:50 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-06-2009
patrykxes patrykxes is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 23
Sort, group rows

I wrote script in bash which generates this report:

User1,admin,rep,User2,shell,path1,x1,r1
User2,admin,rep,User7,shell,path1,x1,r1
User3,admin,rep,User4,shell,path1,x1,r1
User4,admin,rep,User3,shell,path1,x1,r1
User5,admin,rep,User1,shell,path1,x1,r1
User6,admin,rep,User5,shell,path1,x1,r1
User7,admin,rep,User6,shell,path1,x1,r1
...

I would like so that (UserX):

User1,admin,rep,User1,shell,path1,x1,r1
User2,admin,rep,User2,shell,path1,x1,r1
User3,admin,rep,User3,shell,path1,x1,r1
User4,admin,rep,User4,shell,path1,x1,r1
User5,admin,rep,User5,shell,path1,x1,r1
User6,admin,rep,User6,shell,path1,x1,r1
User7,admin,rep,User7,shell,path1,x1,r1
...

How to do this ?
Thx
  #2 (permalink)  
Old 01-06-2009
the wonderer the wonderer is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
Hi mate,

What do u mean? Do u want to sort the entries according to one of the columns?
  #3 (permalink)  
Old 01-06-2009
the wonderer the wonderer is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
Quote:
Originally Posted by the wonderer View Post
Hi mate,

What do u mean? Do u want to sort the entries according to one of the columns?
OK I got it !

I will c if I can help ..
  #4 (permalink)  
Old 01-06-2009
patrykxes patrykxes is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 23
Hi

Source report:

User1,admin,rep,User2,shell,path1,x1,r1
User2,admin,rep,User7,shell,path1,x1,r1
User3,admin,rep,User4,shell,path1,x1,r1
User4,admin,rep,User3,shell,path1,x1,r1
User5,admin,rep,User1,shell,path1,x1,r1
User6,admin,rep,User5,shell,path1,x1,r1
User7,admin,rep,User6,shell,path1,x1,r1
User8,admin,rep,,,path1,x1,r1
User9,admin,rep,,,path1,x1,r1
User10,admin,rep,,,path1,x1,r1
User11,admin,rep,,,path1,x1,r1
...

I'd like to assign user names with numbers User2,User7,User4,User3,User1... from the fourth column to the same users from the first column, so as to obtain the following report:

User1,admin,rep,User1,shell,path1,x1,r1
User2,admin,rep,User2,shell,path1,x1,r1
User3,admin,rep,User3,shell,path1,x1,r1
User4,admin,rep,User4,shell,path1,x1,r1
User5,admin,rep,User5,shell,path1,x1,r1
User6,admin,rep,User6,shell,path1,x1,r1
User7,admin,rep,User7,shell,path1,x1,r1
User8,admin,rep,,,path1,x1,r1
User9,admin,rep,,,path1,x1,r1
User10,admin,rep,,,path1,x1,r1
User11,admin,rep,,,path1,x1,r1
...

ps.
only users User2,User7,User4,User3,User1... from the fourth column have shell
  #5 (permalink)  
Old 01-06-2009
patrykxes patrykxes is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 23
Help me please.
  #6 (permalink)  
Old 01-06-2009
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 167
something like this ?


Code:
$ awk 'BEGIN {FS=OFS=","} $4!="" {$4=$1} {print}' es.txt

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0