LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 02-12-2004, 11:22 AM   #1
michael_util
Member
 
Registered: Feb 2004
Posts: 47

Rep: Reputation: 15
MAJOR problem .. bash scripts ... HELP !!!


Hello,

I am writing a bash script to do a compare between 8 files and fine the common lowest multipler.

I can not use diff because of the file format and how it changes.

So I started off with an array loop

#!/bin/bash

declare -a masnew

index=0
cat file1 | while read line
do
masnew[$index]="$line"
let "index = $index + 1"
echo ${masnew[6]} ### used for test
done

echo ${masnew[6]} ### used for test

Ok ... now inside the loop the echo statement prints the 6th element of the array repeatedly as it should. Out side the loop it print " ". That is right a null value. The array is completely empty out side the loop ?

I having tried this on slackware 9.1, 9.0 and 8.1 with all the same results. I have tried different shells. I have even compiled bash from source.

I have not get this to work, I this for a project I am doing so it is important.

Any suggestions would help !!!!

Michael.
 
Old 02-12-2004, 12:08 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php
 
  


Closed 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



Similar Threads
Thread Thread Starter Forum Replies Last Post
little help with bash scripts sniff Programming 2 10-26-2005 05:17 PM
bash scripts hoffmanyew Programming 3 08-11-2005 01:27 AM
Bash Scripts Skute Programming 7 03-12-2004 10:17 AM
MAJOR problem ... bash script array HELP !!!!! michael_util Slackware 1 02-13-2004 06:51 AM
Bash scripts? BajaNick Programming 3 07-05-2003 10:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:58 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