First post, I'm not a UNIX script guru and am trying to hack together something as a requirement ASAP.
I have scanned the forums and Googled for this and have found similar issues but no usable solutions so I am hoping one of you guys can help me out.
Basically I have a batch file filled with data -- a mock up example is below:
Amongst some other things, I need to extract all instance of lines that are "trailer" records which are indicated with "IMATRL".
I can do that quite easily with grepping. However, in my eventual processings script, I need to get all trailer records out into an array so that I can then use them as a basis of analysing the file for statistical purposes (matching trade data passed in vs what is processed out, etc)
My problem is that no matter what I do, I simply cannot get the "whole line" extracted out into an array. I've tried various playings with 'awk' but it hasn't worked:
But it dumps out everything to invidual elements :
Running the basic grep on the command line prints out the 3 lines with neat little "\n" so it looks like what I'd want. But in script, it obviously resolves the grep result to a single string which is then using a single " " whitespace as the tokeniser for the array creation.
Can anyone help me get my array output to look like this :
And without using a temp file to dump results to before re-parsing?
As for the 1023 limit - that should be fine -- the batch files I have to process should at *most* have maybe 5 to 6 entries that need to be extracted for array purposes and the lines in production are 80chars in length so that's fine.
Hello All,
Can you please help me with the below.
#!/bin/bash
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5 EXTRACT_DT:30-SEP-12 VER_NUM:1"
ARR="No Differences In Stage Between HASH_TOTALS & HASH_TOTALS_COMP For UNINUM:0722075 PROVIDER:5... (14 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)
Hello together,
first of all, iam really a beginner in Shellskripting and i need some help please. Following Task i try to finished:
vmtoolsd --cmd 'info-get guestinfo.ovfEnv' > vmt
In the file vmt are some strings that iam searching for.
For that i try to create a array like:
... (2 Replies)
hi people,
I have a text file containing data, seperated by TAB. I want to process this tab'ed data as variable. how can I assign this?
Ex:
11aaa 12000 13aaa 14aaa 15aaa 16aaa 17aaa
21aaa 22000 23aaa 24aaa 25aaa 26aaa 27aaa
31aaa 32000 33aaa 34aaa 35aaa 36aaa 37aaa
41aaa 42000 43aaa... (5 Replies)
Hi,
Is there any way I can grep an array against another array?
Basically here's what I need to do.
There will be an array containing some fixed texts and I have to check whether some files contain these lines. Reading the same files over and over again for each different pattern doesnt seem... (1 Reply)
Using the bash shell I am trying to read in 2 files. The first file (file1) is a list of names to search for in (file2). If a name in file1 is found in file2 I want the entire line in file2 to be printed to an output file. File1 consists of a single column of names. File2 consists of several... (2 Replies)
Hi,
I have a reqmt as i have some values in array and I want to search each value in a file by grep command.
Here goes my scripting:
#!/bin/ksh
set -A ArrayA CENTER LEFT RIGHT
echo "ArrayA contains: ${ArrayAİ*¨}"
grep -e "${ArrayAİ*¨}" filename.txt
The above grep is working for... (4 Replies)
Hi Guys,
I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys.
MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' `
Harby. (4 Replies)
Hi,
I have the following array.
@a=( ,);
and want to
push @a,()
if the 6 is not in the $a.
This is simplified out of a longer script but im trying for days now and get sick of it.
Can any of you help me on this.
Cheers
Markus (1 Reply)
hi all
i have 2 array one is refernce array where as other array is generated from text file. array A has all letters from A-z and a-z and i want to find out which letters are missing in generated array and push them in another array to display them.
i have following code ....
for my $ref... (1 Reply)