LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 12-22-2013, 11:25 PM   #1
doomaway
LQ Newbie
 
Registered: Apr 2012
Posts: 12

Rep: Reputation: Disabled
Red face bash parallel cant generate correct array like my error shell demo


hi all ,below is my script any suggetion

Quote:
#!/bin/bash
tmp_fifofile="/tmp/$.fifo"
mkfifo $tmp_fifofile
exec 6<>$tmp_fifofile
rm $tmp_fifofile
thread=1
for ((i=0;i<$thread;i++));do
echo
done >&6 #
#item1
for (( j=0;j<10;j++ ))
do
brr[$j]=`echo $RANDOM`
done
#item2
for (( i=0;i<10;i++ ))
do
read -u6
{
arr[$i]=`echo $RANDOM`
echo >&6
} &
done
wait
exec 6>&- # close f6

#print info

echo "array equal"${arr[1]}
echo "brray equal"${brr[1]}
echo "gerenate array Successful"
#end

item1 generate array general way

item2 generate brray by parallel way

so perform result is
[root@doom tbctemp]#sh 2.t
array equal
brray equal8516
gerenate array Successful



give me a helping hand
thanks in advances!
 
Old 01-13-2014, 12:27 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Sorry, I refuse to read scripts without indentation.
 
Old 01-13-2014, 02:10 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008

Rep: Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193Reputation: 3193
In the Op's defense, he has simply used the wrong bbcode.

OP - Please change the 'quote' tags to 'code' tags and your formatting will be preserved
 
  


Reply

Tags
bash coproc example



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
How to use a variable to index an array in Bash shell script? anotheremily Programming 3 06-22-2012 09:46 PM
[SOLVED] Bash shell array processing slower than expected steven.c.banks Linux - General 6 04-20-2012 01:10 AM
[SOLVED] largest numbers from an array - Shell/Bash Script ChozN Programming 5 03-22-2012 11:18 AM
bash shell script split array robertngo Programming 13 06-19-2011 11:01 PM
Bash Shell Scripting - using ls into array aliasofmike Programming 5 11-05-2007 03:00 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:14 AM.

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