Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 03: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, 04:10 AM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

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

Rep: Reputation: 210Reputation: 210Reputation: 210
what catkin said.

Last edited by jhwilliams; 11-10-2011 at 04:24 AM. Reason: catkin's answer is more sensible
Old 11-10-2011, 05: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-02-2015 11:17 PM
How to pass a c variable to a bash script? daYz Programming 3 09-28-2007 08:30 AM
how to pass a keystroke to a bash script? minike Programming 5 01-21-2007 11:42 AM
bash script help (arrays and strings from files) nkoplm Programming 14 12-02-2005 09:50 AM
bash script - variables & arrays question rblampain Linux - Software 4 09-25-2004 09:57 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:32 PM.

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