Actually my requirement is to get values from line by line in a file and assign to variable, it is good that for each line if there is separate variable also, from the above idea provided.
We get asked for this more often than you can imagine, but to date nobody's ever given a better reason for it than "it seemed like a good idea at the time". It's always silly -- how would you even use those variables? It'd take much eval madness to do a loop over variable1 ... variablen but a loop over an array is trivial.
Thanks, Let me explain the reason, we are writting scripts and our superiors want them as HTML reports,
we have some security reasons so we are not allow html packages from db side, only solution we have is through shell script ,
files which are huge in row wise as well as column wise doesnt make any sense of making awk of some minimum 20 or above in a file,
so we required two loops in line wise as well as getting the data inside the line,
i came to heard that korn shell doesnt support multidimensional array ,
atleast single dimension is possible for each line if there is separate variable that could be possible to call them in array,
Thanks anyway, If any solution by chance if found or worked Please do let me know.
And If possible anyone could give example on "eval", hopefully that could be useful to me.
I get from that:
1) You have huge files
2) You must output HTML
3) You'd like multidimensional arrays
This actually sounds like exactly the kind of situation awk is meant for. It has things you can easily use as huge multidimensional arrays, and even if your lines are bigger than its line-length limit(which GNU/linux awk doesn't have, anyway) you can abuse the value of RS to read one field at a time instead.
Shell on the other hand is very poor for this. It doesn't have anything like multidimensional arrays, its performance is poor, and its variables are liable to be very limited in size.
I can show you more detail on this if you tell us more about what you want rather than details on the hoops you'd expected to jump through to do so.
Last edited by Corona688; 08-19-2013 at 01:53 PM..
Whilst I fully accord with Corona688 about better not suboptimize but take the whole picture into account to find a good solution, here's a small bashism that might do what you're so eager for:
Your file's lines will be in WORD1, WORD2,... WORDn arrays.
Not sure if and/or how this works in ksh.
Thanks , the script worked well in ksh, now using your script each variable can be applied for each line ,
It is very helpful to me , But i am getting error while trying to use while loop or until after "eval" to get variable array's each element.
I will search the forum to get suitable result, meanwhile if anybody has solution it could be fine for me.
I should not expect more anyway i will workaround to get and if anyone knows Please do let me know.
tried with "while" also same error.
---------- Post updated at 01:05 PM ---------- Previous update was at 12:33 PM ----------
Thanks , i will try awk RS variable too, if this is achived and there wont be any loop again,
I wil try to come up and will post for review/suggestion.
Hi , Thanks , Now i understood that through shell it is not possible to make loop in main variable decomposing it to arrays of elements inside that each array further fetching array as array is not possible,
Please correct me if i am wrong this kind of multidimensional array and nested concept is available in PERL right.
I figured it out my script, Please let me know your suggestion or advise, how better this can be written.
Please help to fetch the values for a key from below data format in linux.
Sample Input Data Format
11429510|PurchaseCondition|GiftQuantity|1... (2 Replies)
I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables.
I need to read this file which is an input to my script
file name, first path, second... (7 Replies)
I have connected to oracle database with sqlplus -s / <<EOF
select ename, age from emp where empid=1234;
I want to save the values of ename and age in unix shell variables. Any pointers would be welcome..
Thanks in advance!!1
Cheers :):):):) (1 Reply)
Hello, How All are Doing today. I have a issue, I have a file which contains the data as follow
<ENVELOPE><ENVELOPE_ID>TEST</ENVELOPE_ID><ENVELOPE_EXTERNAL_ID></ENVELOPE_EXTERNAL_ID><ENVELOPE_VERSION>2</ENVELOPE_VERSION><SIResourceDefaultVersion>true</SIResourceDefaultVersion><TYPE>GS... (1 Reply)
I wanted to get the software to be fetched from the Service Provide URL to my unix server. I tired using the mget, but resulted in error. Please take a look.
$ wget -O V3-0-5-2.Solaris8-SPARC.tar.gz --http-user=hd87es3 --http-passwd=987dnja7 http://beyond.abinitio.com... (3 Replies)
i have a file which have a pattern like this
Nov 10 session closed
Nov 10 Nov 9 08:14:27 EST5EDT 2010 on tty .
Nov 10 Oct 19 02:14:21 EST5EDT 2010 on pts/tk .
Nov 10 afrtetryytr
Nov 10 session closed
Nov 10 Nov 10 03:21:04 EST5EDT 2010
Dec 8 Nov 10 05:03:02 EST5EDT 2010
... (13 Replies)
I have text file in the following strucher .
The files contain hondreds of lines.
I would like to get back the line with lowest date (values4 field).
In this case its line number 3.
groupb;Database;0;20110201122641... (4 Replies)
I've been struggling with this for some time but can't find a way to do it and I haven't found any other similar thread.
I'd like to get the 'fields' in a line from a file into variables in just one command.
The file contains data with the next structure:... (4 Replies)
I want to fetch passwords from a common file xxxx.txt and use it in a script.
Currently the password is hardcoded so this have to be changed so that password can be fetched from text file.....
Please reply asap..
Thanks (4 Replies)
i have a configuration file that looks like
where 20 is the number of threads in the thread pool initially.
net04.xxxxx.edu is the hostname.
and 7080 7988
are two ports. first one for client requests and second one for dns communication. now my... (2 Replies)