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
Merging two command into single line kingganesh04 UNIX for Advanced & Expert Users 2 02-04-2009 09:45 AM
ls command output in single line arsheshadri AIX 7 04-28-2008 02:50 PM
run command Unix on a single line Riddick61 UNIX for Dummies Questions & Answers 8 02-04-2008 02:19 PM
what does echo $$ command display suri Shell Programming and Scripting 2 03-06-2007 03:01 AM
single line command roshanjain2 Shell Programming and Scripting 4 02-07-2007 05:33 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 03-04-2009
sakthifire sakthifire is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 26
Need a Command To display "echo command value in loop" in single line.

Hi
I want to display "echo command value in loop" in single line. My requirement is to show the input file (test_1.txt) like the output file (test_2.txt) given below.

Input file :test_1.txt
a1|b1|4|5
a1|b1|42|9
a2|b2|32|25
a1|b1|2|5
a3|b3|4|8
a2|b2|14|6

Output file:test_2.txt
a1|b1|4|5|42|9|2|5
a2|b2|32|25|14|6
a3|b3|4|8

The Highlightened same color values which come after "a" and "b" comes in same row in out put file.

Tq
Sakthifire

Last edited by sakthifire; 03-04-2009 at 09:34 AM..
  #2 (permalink)  
Old 03-04-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,300
Use nawk or /usr/xpg4/bin/awk on Solaris.

Code:
awk -F"|" '{a[$1$2]=a[$1$2]?a[$1$2] FS $3 FS $4:a[$1$2]=$0}
END{for(i in a)print a[i]}
' test_1.txt > test_2.txt
Regards
  #3 (permalink)  
Old 03-04-2009
sakthifire sakthifire is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 26
Awesome ... Great ... in Span of 10 mins you found it .

Thank you a lot ...

Regards
Sakthifire
Closed Thread

Bookmarks

Tags
awk command

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 08:11 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