The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
how to delete records with the given line numbers mad_man12 Shell Programming and Scripting 5 3 Weeks Ago 03:09 AM
records in a line theshashi Shell Programming and Scripting 7 10-02-2009 06:06 PM
delete records using line number(NR) tkbharani UNIX for Advanced & Expert Users 3 01-31-2008 09:56 AM
AWK Multi-Line Records Numbering Problem RacerX Shell Programming and Scripting 3 11-01-2007 10:44 AM
AWK Multi-Line Records Processing RacerX Shell Programming and Scripting 10 10-18-2007 08:46 PM

Reply
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 2 Weeks Ago
Zopilota Zopilota is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 3
Arrow Singled line records

Hi,
I´m new on this Linux groups and like to learn more,
Right now, I´m working on a project (personal) and have a question fallowing problem
I´m making a bash script to read many files and extract some fields and separate them according certain criteria, let say a have a big file with records like these
210,linux
211,linux
220,windows
230, solaris
240, linux
250,ubuntu
Now I made an awk process to make 4 different files:
Linux.txt
210,linux
211,linux
212, linux ….219
Windows.txt
220,windows…220
Solaris.txt
230.solaris…239
Ubuntu.txt
250,ubuntu…259
Here is where the fun begin, I already remove field 2 from each file, but can not make all records on a singled line, I need them all like look this
Linux.txt
210,211,212,…219
Windows.txt
220…229
Solaris.txt
230,…230
Ubuntu.txt
250,…259

Any help would be appreciated.

Zopilota
  #2 (permalink)  
Old 2 Weeks Ago
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,305
Looks like homework, what kind of project is this?

Can you show us what you have attempted so far?
  #3 (permalink)  
Old 2 Weeks Ago
Zopilota Zopilota is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 3
Hi,

Hope it was a homework.

This is what I have so far.

Code:
while read line ;do
    grep $line $fileTre | awk 'BEGIN {FS = ","} ; {print $59}' >> $line'_'$fileFor
done < $fileTwo
With this I open a file $fileTwo for Reading and made a loop
Get $line value whish is normali a name (let say linux in first place)
from $fileTree and extract only field $59 (210, 211…219) and make a new file $line_$fileFor wich would be linux_fileFor for example.

Last edited by Franklin52; 2 Weeks Ago at 05:39 PM.. Reason: Please use code tags!!
  #4 (permalink)  
Old 2 Weeks Ago
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,305
Ok, I hope I'm wrong.

Code:
awk -F, '{a[$2]=a[$2]?a[$2]FS$1:$1}END{for(i in a){print a[i] > i ".txt"}}' file
If this is new for you, you can have a read of The GNU Awk User's Guide.
  #5 (permalink)  
Old 2 Weeks Ago
Zopilota Zopilota is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 3
Thank you very much, it realy works.



Zopilota
Reply

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 02:33 PM.


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