I have 2 files
File data always will have single record.
I the above case, if I want to extract value of AMOUNT from file data.
First I'll have to find position of AMOUNT in template and extract the specified column from the data.
Following is my code
Since I do not know the exact column position, I'm using $pos in the script. Which is a error. Can anybody give me a solution.
Hi all,
I have been struggling with this all day, and it is key to a conversion database I have to write.
The data converts the information out of an array using AWK, and basically all I have to do is figure out how to get the value of a variable inside a variable.
Right now at its... (11 Replies)
Dear All,
we have a command output which looks like :
Total 200 queues in 30000 Kbytes
and we're going to get "200" and "30000" for further process. currently, i'm using :
numA=echo $OUTPUT | awk '{print $2}'
numB=echo $OUTPUT | awk '{print $5}'
my question is : can I use just one... (4 Replies)
Hi all,
i have a data array as follows.
array=ertfgj2345
array=456ttygkd
.
.
.
array=errdjt3235
so number or elements in the array can varies depending on how big the data input is.
now i have a variable, and it is $1 (there are $2, $3 and so on, i am only interested in $1).
... (9 Replies)
Hi all,
Hope someone can help me out here.
I have this BASH script (see below)
My problem lies with the variable path.
The output of the command find will give me several fields. The 9th field is the path. I want to captured that and the I want to filter this to a specific level.
The... (6 Replies)
Hello experts,
I'm stuck with this script for three days now. Here's what i need.
I need to split a large delimited (,) file into 2 files based on the value present in the last field.
Samp: Something.csv
bca,adc,asdf,123,12C
bca,adc,asdf,123,13C
def,adc,asdf,123,12A
I need this split... (6 Replies)
i have this variable:
varT="1--2--3--5"
i want to use awk to print field 3 from this variable. i dont want to do the "echo $varT".
but here's my awk code:
awk -v valA="$varT" "BEGIN {print valA}"
this prints the entire line. i feel like i'm so close to getting what i want. i... (4 Replies)
I have the following script, and I want to assign the output ($10 and $5) from awk to N and L:
grdinfo data.grd | awk '{print $10,$5}'| read N L
output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the variables are associated with each other.
Any guidance is appreciated.
File that contains the... (6 Replies)
Discussion started by: ncwxpanther
6 Replies
LEARN ABOUT DEBIAN
file::randomaccess
File::RandomAccess(3pm) User Contributed Perl Documentation File::RandomAccess(3pm)NAME
File::RandomAccess - Random access reads of sequential file or scalar
SYNOPSIS
use File::RandomAccess;
$raf = new File::RandomAccess(*FILE, $disableSeekTest);
$raf = new File::RandomAccess($data);
$err = $raf->Seek($pos);
$num = $raf->Read($buff, $bytes);
DESCRIPTION
Allows random access to sequential file by buffering the file if necessary. Also allows access to data in memory to be accessed as if it
were a file.
METHODS
new Creates a new RandomAccess object given a file reference or reference to data in memory.
# Read from open file or pipe
$raf = new File::RandomAccess(*FILE);
# Read from data in memory
$raf = new File::RandomAccess($data);
Inputs:
0) Reference to RandomAccess object.
1) File reference or scalar reference.
2) flag set if file is already random access (disables automatic SeekTest).
Returns:
Reference to RandomAccess object.
SeekTest
Performs test seek() on file to determine if buffering is necessary. If the seek() fails, then the file is buffered to allow random
access. SeekTest() is automatically called from new unless specified.
$result = $raf->SeekTest();
Inputs:
0) Reference to RandomAccess object.
Returns:
1 if seek test passed (ie. no buffering required).
Notes:
Must be called before any other i/o.
Tell
Get current position in file
$pos = $raf->Tell();
Inputs:
0) Reference to RandomAccess object.
Returns:
Current position in file
Seek
Seek to specified position in file. When buffered, this doesn't quite behave like seek() since it returns success even if you seek
outside the limits of the file.
$success = $raf->Seek($pos, 0);
Inputs:
0) Reference to RandomAccess object.
1) Position.
2) Whence (0=from start, 1=from cur pos, 2=from end).
Returns:
1 on success, 0 otherwise
Read
Read data from the file.
$num = $raf->Read($buff, 1024);
Inputs:
0) Reference to RandomAccess object.
1) Buffer.
2) Number of bytes to read.
Returns:
Number of bytes actually read.
ReadLine
Read a line from file (end of line is $/).
Inputs:
0) Reference to RandomAccess object.
1) Buffer.
Returns:
Number of bytes read.
Slurp
Read whole file into buffer, without changing read pointer.
Inputs:
0) Reference to RandomAccess object.
Returns:
Nothing.
BinMode
Set binary mode for file.
Inputs:
0) Reference to RandomAccess object.
Returns:
Nothing.
Close
Close the file and free the buffer.
Inputs:
0) Reference to RandomAccess object.
Returns:
Nothing.
AUTHOR
Copyright 2003-2011 Phil Harvey (phil at owl.phy.queensu.ca)
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO Image::ExifTool(3pm)perl v5.12.4 2011-01-03 File::RandomAccess(3pm)