File1 - input_file
-----
tmp_value|3|number||
tmp_value1|3|alpha||
tmp_value2|6|alpha|AA AA|
tmp_value3|15|number|000000005|
tmp_value4|15|number|000000000000000|
tmp_value5|11|alpha|bbbbbbbbbbb|
tmp_value6|11|alpha|bb bb|
input_file definition
-------------------
column1 = field_name
column2= field_length
column3= datatype
column4=value for the field
File2 - description_file
-----
tmp_value2|1|1|6|alpha|
tmp_value4|2|7|15|number|
tmp_value1|3|22|3|alpha|
tmp_value3|15|25|15|number|
reserved1|5|40|10|alpha|
filler1|6|50|6|number|
tmp_value6|7|56|11|alpha|
description_file definition
----------------------
column1 = field_name
column2= s1.no
column3= offset
column4=field_length
column5=datatype
fillers can be = fillers1 ...filler<n>
reserved can be = reserved1... reserved<n>
Total length of string can be 6+15+3+15+10+6+11 =66
The resulted inputstring needed as per description_file is
|AA AA 000000000000000 000000000000005 000000bb bb |
Description of above result
tmp_value2|1|1|6|alpha| ------------> value is |AA AA | (spaces for remaining 1 character)
tmp_value4|2|7|15|number| ----------> value is |000000000000000| samelength so subsitituted as same
tmp_value1|3|22|3|alpha| ----------> value is | | - it is empty in input_file so subsituted spaces
tmp_value3|15|25|15|number| --------> value is |000000005| - filled remaining zero's leading
reserved1|5|40|10|alpha| ------------> value is | | - it is reserved with alpha as datatype so subsituted spaces
filler1|6|50|6|number| --------------> value is |000000| - it is filler with number as datatype so subsituted zero's
tmp_value6|7|56|11|alpha|-----------> value is |bb bb | - (spaces for remaining 6 character)
Code:
Conditions are:
1)I need to loop thru description file each line with each line in input_file.
2)if column1 in both file r equals then i need to take the value of column4 in input_file and have it in a string.
3)For the above there r certain conditions
if column1=column1
then take column4 of input_filevalue
if column4 of input_file value length equals length =column4(field_length) of description_file
result=result+column4(field_value)
if column4(field_value) length is not equal to field_length
if column5(datatype) = number
fill leading zero's to the value to make to that field_length
then
result=result+value
if column5(datatype) = alpha
fill trailing spaces to value to make to that field_length
then
result=result+value
if column1(description_file) not present in input_file
if column5(datatype) = number
then
fill zero's to the value to make to that field_length
result=result+value
if column5(datatype) = alpha
then
fill spaces to value to make to that field_length
result=result+value
if column1(description_file) has string reserved or filler
if column5(datatype) = number
then
fill zero's to the value to make to that field_length
result=result+value
if column5(datatype) = alpha
then
fill spaces to value to make to that field_length
result=result+value
i wrote a shell script for by refering unix.com but still i am not getting proper
result and trailing spaces and forming of string is not correct
---------- Post updated at 01:05 AM ---------- Previous update was at 12:44 AM ----------
i am not much familler in shell script .. so need help on this
Hello
Has anyone got an example shell script that I can use to compare the contents of two files.
The files should contain the same contents, eg.
file1.txt
apple
pear
grape
file2.txt
apple
pear
grape (2 Replies)
hello ....i am new in shell script..I have one shell script which read inputs from file...and second is c++ pgm..i call my script from c++ programm..to compare file values to c++ pgm value..
our shell script is shubhi.sh
#! /bin/sh
while read line
do
echo -e"$line"
done<file1
this script... (1 Reply)
All,
PLease can you help me with a shell script which can compare two xml files and print the difference to a output file.
I have attached one such file for you reference.
<Group>
<Member ID=":Year_Quad:41501" childCount="4" fullPath="PEPSICO Year-Quad-Wk : FOLDER.52 Weeks Ending Dec... (2 Replies)
hi,
i have a text file that looks like this!
i want to generate an excel sheet out of it, removing all the junk data except the addresses
that look like
. Arrow Electrical Services
Rotating Machinery, Electrical Contracting & Mining Specialists
Onsite maintenance, breakdown... (8 Replies)
Hi All,
Can anyone give me Shell script sample script to generate Param file by Reading Values from SQL Plus query and it should assign those values to variables like..
$$SChema_Name='ORCL'
Thanks in Advance... Srav... (4 Replies)
I have a file lets say input.csv having two columns like-
Name,Mobile No
A,111
B,222
A,333
A,123
B,213
I would like to find result in a new file lets say output.csv as-
Name,Mobile No
A,111
B,222
means short the file on the basis of first column and first value corresponding to the... (5 Replies)
Hi,
I want 10000+ unique Audio file of approx 2MB each. How can i generate numerous audio files using shell script. Any tool, command or suggestions are welcome.
If i give one audio seed file then can we create numerous unique files with same seed file?
Any help is highly appreciable.... (11 Replies)
I have below 2 requirements for parameterize the generate the extract file from Oracle table using Shell Script. Could you please help me by
modifying the script and show me how to execute it.
First Requirement:
I have a requirement where I need to parameterize to generate one... (0 Replies)
Shell script logic
Hi
I have 2 input files like with file 1 content as (file1)
"BRGTEST-242" a.txt "BRGTEST-240" a.txt "BRGTEST-219" e.txt
File 2 contents as fle(2)
"BRGTEST-244" a.txt "BRGTEST-244" b.txt "BRGTEST-231" c.txt "BRGTEST-231" d.txt "BRGTEST-221" e.txt
I want to get... (22 Replies)
Hi,
I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service)
lets say, if I run my script ./test.sh, the output should be... (3 Replies)