Home » Infrastructure » Unix » Frank.bit of confusion.so new message has been posted.
Frank.bit of confusion.so new message has been posted. [message #98179] Wed, 21 April 2004 21:20 Go to next message
Venky
Messages: 52
Registered: October 2001
Member
Hi Frank,

Please provide me the complete code for the cited example. I really didn't know how to modify the code and I tried with the fragment of code given by you. Please note that the fields are separated by pipe(&#124) and not with comma(,). There are two files as given below.

PNC04212004.dat
----------------
xyz&#124abc?
abc&#124xzy𞖷
mno&#124asdf𞓦

PNC04222004.dat
---------------
asdf&#124gfg?
lkjlj&#124lhhi?
jghj&#124hhhh?

Now with unix shell scripting I need a single file PNC.dat like below. The file name of the corresponding file is the first field.

PNC.dat
-------
PNC04212004&#124xyz&#124abc?
PNC04212004&#124abc&#124xzy𞖷
PNC04212004&#124mno&#124asdf𞓦
PNC04222004&#124asdf&#124gfg?
PNC04222004&#124lkjlj&#124lhhi?
PNC04222004&#124jghj&#124hhhh?

Please help me....

Regards,

Venky.
Re: Frank.bit of confusion.so new message has been posted. [message #98184 is a reply to message #98179] Fri, 23 April 2004 08:54 Go to previous message
jan
Messages: 71
Registered: August 2002
Member
td=`date +%m%d%y%H%M%S`
mv pnc.dat oldpnc$td.dat
lin="1"
sc=''
for s in pnc*.dat
do
nol=`wc -l $s&#124tr -s " "&#124cut -f2 -d" "`
sc=`head -$lin $s&#124tail -1`
while [[ $lin -le $nol ]]
do
sc=`head -$lin $s&#124tail -1`
data=`echo $s&#124cut -f1 -d"."`
echo $sc
echo $data'|'$sc>>pnc.dat
lin=`expr $lin + 1`
done
lin="1"
done

NOTE: please make sure that all the PNC files has one blank line at the end.
This script will rename any existing PNC.DAT so that it doesn't over write/append existing pnc.dat file.

you can modify the script as per your requirement...

hope this helps

Jan
Previous Topic: Oracle on DGUX
Next Topic: Transforming an embedded PL/SQL exception to exit from shell script
Goto Forum:
  


Current Time: Thu Mar 28 15:00:50 CDT 2024