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
foreach loop + 2 variables JamesGoh Shell Programming and Scripting 3 06-04-2008 03:36 AM
using variables outside a while loop Tornado Shell Programming and Scripting 2 02-09-2007 01:26 AM
adding variables for, for loop jazz High Level Programming 3 03-13-2006 04:23 AM
Writing to variables within a loop Sniper Pixie UNIX for Dummies Questions & Answers 0 03-02-2006 09:11 AM
for loop with multiple variables ? fosterian Shell Programming and Scripting 3 03-01-2004 05:15 AM

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 07-04-2009
pankajpw pankajpw is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 2
I am not interested in any hijacking....was just need a help..
  #2 (permalink)  
Old 07-04-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by pankajpw View Post
I am not interested in any hijacking....was just need a help..

Then start a new thread (and explain the method that leads from your input to your desired output).

(And look at the paste command.)
  #3 (permalink)  
Old 06-30-2009
rakeshawasthi rakeshawasthi is offline
Registered User
  
 

Join Date: Aug 2004
Location: India
Posts: 379
$#
it will give the no of parameters passed
  #4 (permalink)  
Old 06-30-2009
kshji's Avatar
kshji kshji is offline
Registered User
  
 

Join Date: Jun 2009
Location: Finland
Posts: 236
One more, using set to array.
Code:
#!/usr/bin/ksh
set -A array1 $(cat list1)
set -A array2 $(cat list2)
n=${#array1[*]}
i=0
while (( i < n ))
do
     print "${array1[$i]} ${array2[$i]}"
    ((  i+=1  ))
done
  #5 (permalink)  
Old 06-30-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
Quote:
Originally Posted by kshji View Post
One more, using set to array.
Code:
#!/usr/bin/ksh
set -A array1 $(cat list1)
set -A array2 $(cat list2)
n=${#array1[*]}
i=0
while (( i < n ))
do
     print "${array1[$i]} ${array2[$i]}"
    ((  i+=1  ))
done
why exactly do you a 'cat'?
Use '<' for ksh/bash.
  #6 (permalink)  
Old 06-30-2009
kshji's Avatar
kshji kshji is offline
Registered User
  
 

Join Date: Jun 2009
Location: Finland
Posts: 236
Yes in this case this is enough. My idea was more generally example, some commands give some list and use it.
set -A array1 $(<list1)
set -A array2 $(<list2)
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 06:26 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