![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Reading a binary file in text or ASCII format | Nagendra | High Level Programming | 3 | 12-03-2008 06:11 PM |
| Reading a mailbox and sending new messages to a text file | rsw626 | Shell Programming and Scripting | 1 | 04-17-2008 01:35 PM |
| Help with reading text file | bilal05 | UNIX for Dummies Questions & Answers | 1 | 04-12-2008 03:46 PM |
| Reading from Text file..... | user__user3110 | Shell Programming and Scripting | 0 | 04-11-2008 05:18 AM |
| reading text file | jaan | Shell Programming and Scripting | 1 | 02-16-2004 08:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Reading text from a file
Guys,
I am trying to read text from a file, into arrays. The format of the file is: @DATABASE femotest @PACKAGE_SPECS /usr/home/oracle92/sosa/scripts/test.pks /usr/home/oracle92/sosa/scripts/rep.pks @PACKAGE_BODIES /usr/home/oracle92/sosa/scripts/rep.pkb @PROCEDURES @FUNCTIONS @TRIGGERS @VIEWS @SQL_SCRIPTS Where there can be any number of lines between each entry, I want to read these all into seperate arrays and a single variable for the database sid. I know how to grep for particular parts in the file, but its more getting the lines between them, could anyone give me some suggestions on how this can be done? Again thanks. |
|
||||
|
Aigles
Could you explain this section a little further? *) eval ${entry}[\${#${entry}[*]}]='$record' ;; and tbh the second line i am kinda lost with. -- Edit, figured the first line out, i think! Actually think i have figured them both out, thanks! Last edited by LiquidChild; 05-09-2007 at 09:01 AM.. |
|
|||||
|
*) ... ;;
Default case -> line doesn't start with @ -> Entry data *) eval ${entry}[\${#${entry}[*]}]='$record' ;; Generate and execute array assigment. For example : FUNCTIONS[${#FUNCTIONS[*]}='input line' ${#FUNCTIONS[*]} is the actual number of elements of the array. Since the index of array start with 0, it's also the value of the next array element. Jean-Pierre. |
|
||||
|
I have put the following:
readReleaseFile() { #Reads the contents of the release file #Populate the arrays as required init entry= while read record do case $record in @*) entry=`expr substr $record 2 999`;; *) eval ${entry}[\${#${entry}[*]}]=$record;; esac done < $releaseFile } But when I run it I get an error: expr: syntax error ./release.sh[16]: [${#[*]}]=femotest: bad substitution I know why the second line is giving the error, but the expr: syntax error I am not sure about. I have also tried: @*) entry=`expr substr "$record" 2 999`;; Anyone know what syntax is wrong here? Thanks |
|
|||||
|
Quote:
Code:
*) eval ${entry}[\${#${entry}[*]}]='$record' ;;
Jean-Pierre. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|