Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-10-2011, 04:53 AM   #1
LQ Newbie
Registered: Sep 2011
Posts: 14

Rep: Reputation: Disabled
Pass 2 arrays to a BASH script

Need to pass two arrays to a BASH script.

eg: is the script which does some processing and which accepts 2 arrays. Could we call as "a b c d" "1 2 3 4"

Question : How to read the input arguments onto two separate arrays inside script.

thanks in advance.
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 11-10-2011, 05:10 AM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian except for netbook still on Slackware 13.37 (and I have to support Ubuntu)
Posts: 8,572
Blog Entries: 30

Rep: Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182
array1=( $1 )
array2=( $2 )
Reference: here.
3 members found this post helpful.
Old 11-10-2011, 05:22 AM   #3
Senior Member
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 209Reputation: 209Reputation: 209
what catkin said.

Last edited by jhwilliams; 11-10-2011 at 05:24 AM. Reason: catkin's answer is more sensible
Old 11-10-2011, 06:23 AM   #4
LQ Newbie
Registered: Sep 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled

Thanks for the reply and it works.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to deal with bash[$style] arrays in a POSIX compliant script? GrapefruiTgirl Programming 8 01-03-2015 12:17 AM
How to pass a c variable to a bash script? daYz Programming 3 09-28-2007 09:30 AM
how to pass a keystroke to a bash script? minike Programming 5 01-21-2007 12:42 PM
bash script help (arrays and strings from files) nkoplm Programming 14 12-02-2005 10:50 AM
bash script - variables & arrays question rblampain Linux - Software 4 09-25-2004 10:57 AM

All times are GMT -5. The time now is 03:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration