Sponsored Content
Top Forums Shell Programming and Scripting KSH: Reading a file line by line into multiple arrays Post 302323639 by vidyadhar85 on Monday 8th of June 2009 03:41:56 PM
Old 06-08-2009
the var line1 will have what you want.. use how ever you want
Code:
while read line ; do
read line1
echo "$line1"
done < filename

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Ksh Storing Multiple Files and reading each line in each file.

How would I go about storing multiple file paths in a directory that begin like: 20080402* and run a loop that reads each line of each file thats in a given directory. So far this is what I have: #!/bin/ksh echo "ENTER Reprint Date (YYYYMMDD): " read ReprintDate echo ""... (1 Reply)
Discussion started by: developncode
1 Replies

2. Shell Programming and Scripting

Reading a file line by line and processing for each line

Hi, I am a beginner in shell scripting. I have written the following script, which is supposed to process the while loop for each line in the sid_home.txt file. But I'm getting the 'end of file' unexpected for the last line. The file sid_home.txt gets generated as expected, but the script... (6 Replies)
Discussion started by: sagarparadkar
6 Replies

3. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

4. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

5. UNIX for Dummies Questions & Answers

Parsing file, reading each line to variable, evaluating date/time stamp of each line

So, the beginning of my script will cat & grep a file with the output directed to a new file. The data I have in this file needs to be parsed, read and evaluated. Basically, I need to identify the latest date/time stamp and then calculate whether or not it is within 15 minutes of the current... (1 Reply)
Discussion started by: hynesward
1 Replies

6. Shell Programming and Scripting

Reading text file, comparing a value in a line, and placing only part of the line in a variable?

I need some help. I would like to read in a text file. Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01. Is this possible? any help is appreciated. (2 Replies)
Discussion started by: xChristopher
2 Replies

7. Shell Programming and Scripting

Comparison of fields then increment a counter reading line by line in a file

Hi, i have a scenario were i should compare a few fields from each line then increment a variable based on that. Example file 989878|8999|Y|0|Y|N|V 989878|8999|Y|0|N|N|V 989878|8999|Y|2344|Y|N|V i have 3 conditions to check and increment a variable on every line condition 1 if ( $3... (4 Replies)
Discussion started by: selvankj
4 Replies

8. Shell Programming and Scripting

Reading line by line from live log file using while loop and considering only those lines start from

Hi, I want to read a live log file line by line and considering those line which start from time stamp; Below code I am using, which read line but throws an exception when comparing line that does not contain error code tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Discussion started by: ketanraut
2 Replies

9. UNIX for Beginners Questions & Answers

Reading a file line by line and print required lines based on pattern

Hi All, i want to write a shell script read below file line by line and want to exclude the lines which contains empty value for MOUNTPOINT field. i am using centos 7 Operating system. want to read below file. # cat /tmp/d5 NAME="/dev/sda" TYPE="disk" SIZE="60G" OWNER="root"... (4 Replies)
Discussion started by: balu1234
4 Replies
Dumpvalue(3pm)						 Perl Programmers Reference Guide					    Dumpvalue(3pm)

NAME
Dumpvalue - provides screen dump of Perl data. SYNOPSIS
use Dumpvalue; my $dumper = Dumpvalue->new; $dumper->set(globPrint => 1); $dumper->dumpValue(*::); $dumper->dumpvars('main'); my $dump = $dumper->stringify($some_value); DESCRIPTION
Creation A new dumper is created by a call $d = Dumpvalue->new(option1 => value1, option2 => value2) Recognized options: "arrayDepth", "hashDepth" Print only first N elements of arrays and hashes. If false, prints all the elements. "compactDump", "veryCompact" Change style of array and hash dump. If true, short array may be printed on one line. "globPrint" Whether to print contents of globs. "dumpDBFiles" Dump arrays holding contents of debugged files. "dumpPackages" Dump symbol tables of packages. "dumpReused" Dump contents of "reused" addresses. "tick", "quoteHighBit", "printUndef" Change style of string dump. Default value of "tick" is "auto", one can enable either double-quotish dump, or single-quotish by setting it to """ or "'". By default, characters with high bit set are printed as is. If "quoteHighBit" is set, they will be quoted. "usageOnly" rudimentary per-package memory usage dump. If set, "dumpvars" calculates total size of strings in variables in the package. unctrl Changes the style of printout of strings. Possible values are "unctrl" and "quote". subdump Whether to try to find the subroutine name given the reference. bareStringify Whether to write the non-overloaded form of the stringify-overloaded objects. quoteHighBit Whether to print chars with high bit set in binary or "as is". stopDbSignal Whether to abort printing if debugger signal flag is raised. Later in the life of the object the methods may be queries with get() method and set() method (which accept multiple arguments). Methods dumpValue $dumper->dumpValue($value); $dumper->dumpValue([$value1, $value2]); Prints a dump to the currently selected filehandle. dumpValues $dumper->dumpValues($value1, $value2); Same as "$dumper->dumpValue([$value1, $value2]);". stringify my $dump = $dumper->stringify($value [,$noticks] ); Returns the dump of a single scalar without printing. If the second argument is true, the return value does not contain enclosing ticks. Does not handle data structures. dumpvars $dumper->dumpvars('my_package'); $dumper->dumpvars('my_package', 'foo', '~bar$', '!......'); The optional arguments are considered as literal strings unless they start with "~" or "!", in which case they are interpreted as regular expressions (possibly negated). The second example prints entries with names "foo", and also entries with names which ends on "bar", or are shorter than 5 chars. set_quote $d->set_quote('"'); Sets "tick" and "unctrl" options to suitable values for printout with the given quote char. Possible values are "auto", "'" and """. set_unctrl $d->set_unctrl('unctrl'); Sets "unctrl" option with checking for an invalid argument. Possible values are "unctrl" and "quote". compactDump $d->compactDump(1); Sets "compactDump" option. If the value is 1, sets to a reasonable big number. veryCompact $d->veryCompact(1); Sets "compactDump" and "veryCompact" options simultaneously. set $d->set(option1 => value1, option2 => value2); get @values = $d->get('option1', 'option2'); perl v5.16.3 2013-03-04 Dumpvalue(3pm)
All times are GMT -4. The time now is 05:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy