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
Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" iBot UNIX and Linux RSS News 0 01-04-2008 03:00 PM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
how could i make a program mixed with many "|", "<" and ">" strugglingman High Level Programming 2 04-29-2006 08:11 AM
No utpmx entry: you must exec "login" from lowest level "shell" peterpan UNIX for Dummies Questions & Answers 0 01-18-2006 04:15 AM
join two lines when the second line contains "US DOLLAR" powah Shell Programming and Scripting 2 10-21-2005 06:30 PM

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 11-18-2003
hyo77 hyo77 is offline
Registered User
  
 

Join Date: Nov 2003
Posts: 2
Help~~join and "multijoin"

Hi , all
join command can join 2 files, but what about "multijoin"??
if a list of files and an integer are given as input, how to join these files and sort them according to the field number of this integer. Default field is the join field for all the joins.

example:
file 1 = Chris King
file 2 = Chris Funny
file 3 = Chris Small
Chris Big
>multijoin file1 file2 file3 -k 4
result:
Chris King Funny Big
Chris King Funny Small

So, first step is to join file1 and file2, then put it in a file, may call it file10, then join it with file 3, right? but for it's recursive,

i cann't do like this
for i in $*
join $i $i+1 like in other programming languages.
so how to make the output of last join joined with the next file, i really get confused~

well, it's a homework problem, so does anyone have idea??
thanks in advance

Tracy
  #2 (permalink)  
Old 11-19-2003
stevensxiao stevensxiao is offline
Registered User
  
 

Join Date: Nov 2003
Location: BeiJing China
Posts: 4
please try the script below
if the input file is file1 through file3
multijoin.sh
#!/usr/bin/ksh
c=1
for f in file?
do
if [[ c -eq 1 ]];
then
cat $f > tmp
c=2
else
join $f tmp > tmp1
mv tmp1 tmp
fi

done
cat tmp
rm tmp
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 04:08 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