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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to format a .CSV data Uday1982 Shell Programming and Scripting 8 02-04-2008 02:28 AM
how to number format a data file without using SED? Cactus Jack UNIX for Dummies Questions & Answers 3 01-12-2008 04:47 PM
data format from (4.56 0.7) -> 4.6(7) awk?! ahan Shell Programming and Scripting 4 05-07-2006 05:53 PM
format data inquirer Shell Programming and Scripting 2 09-24-2003 03:59 AM
backup data with tar and show them grashuepfer UNIX for Advanced & Expert Users 2 12-05-2002 03:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-04-2006
Registered User
 

Join Date: Jan 2006
Posts: 72
Want to show data in tabel format

Hello ,
I need help to show data in table format

i have 2 files A and B

A files contains 2 coulmns

$1 $2
Test 34
Test1 35
Test4 78
Test6 89


B file contains 2 coulmns
$3 $4
Test 65
Test4 67
Test6 98


The coulmn $1 of A file is equal to $3 of B file . sometimes enteries are missing in the file so i have to first match coulmn $1 and $3 and show enteries like this .

I want to show data in tabel format like this
$1 $2 $4
Test 34 65
Test1 35
Test4 78 67
Test6 89 98


Waiting to hear from your end
Please reply
regards
dips
Reply With Quote
Forum Sponsor
  #2  
Old 05-04-2006
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
Code:
$ cat f1
Test 34
Test1 35
Test4 78
Test6 89
$ cat f2
x x Test 65
x x Test4 67
x x Test6 98
$ join  -a 1 -j1 1 -j2 3 -o 1.1,1.2,2.4 f1 f2
Test 34 65
Test1 35 
Test4 78 67
Test6 89 98
Cheers
Reply With Quote
  #3  
Old 05-04-2006
Registered User
 

Join Date: Jan 2006
Posts: 72
i want to use nawk comand for showing into table format . i will redirect to other file and which will be run in shell script

nawk -f a.awk fileA fileB > output.txt

pls help me
Reply With Quote
  #4  
Old 05-04-2006
Registered User
 

Join Date: Jan 2006
Posts: 72
Post

sorry ... i have 3 column in each file ...
pls read this ....

File A

$1 $2 $3




File B
$4 $5 $6



where $1,$2 of A file is same as $4 $5 of B file

i need output
$1 $2 $3 $6
Test ver10 78 55
Test1 ver5 89 77
Test4 ver6 88
Test ver8 77 66
pls do help
Reply With Quote
  #5  
Old 05-04-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,016
wasn't an extremely similar question asked and answered here?
Reply With Quote
  #6  
Old 05-04-2006
Registered User
 

Join Date: Feb 2006
Posts: 34
I hope this helps

awk 'FNR == NR {a[$1]=$1 $2;b[$1]=$0;next} {print b[$1], $3}' file1 file2
Reply With Quote
  #7  
Old 05-04-2006
Registered User
 

Join Date: Feb 2006
Posts: 34
I missed something in my last post try this

awk 'FNR == NR {a[$1]=$1 $2;b[$1]=$0;next} $1 in a {print b[$1], $3}' file1 file2
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0