Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete variable characters from some field

Status
Not open for further replies.

l3p15

Vendor
May 7, 2005
11
TH
Hi all,

I have made some script to modify data :

MO CELL CHGR TEI SIG DCP1
RXOTRX-0-0 LG300D1 ALL 0 CONC 128

SWVERREPL SWVERDLD SWVERACT DCP2
DEFAULT B0531R0902 B0531R0902 129
130

MO CELL CHGR TEI SIG DCP1
RXOTRX-0-1 LG300D1 ALL 1 CONC 131

SWVERREPL SWVERDLD SWVERACT DCP2
DEFAULT B0531R0902 B0531R0902 132
133

MO CELL CHGR TEI SIG DCP1
RXOTRX-1-0 LG001G1 ALL 0 CONC 128


.
.
.
etc

----------------------------------

and the result that I want to is :

LABSC02 LG300D1 RXOTRX-0-0 RXOTG-0
LABSC02 LG300D1 RXOTRX-0-1 RXOTG-0
LABSC02 LG001G1 RXOTRX-1-0 RXOTG-1
LABSC02 LG001G1 RXOTRX-1-1 RXOTG-1
LABSC02 LG001G2 RXOTRX-1-2 RXOTG-1
LABSC02 LG002G1 RXOTRX-3-0 RXOTG-3
LABSC02 LG002G1 RXOTRX-3-1 RXOTG-3
LABSC02 LG002G2 RXOTRX-3-2 RXOTG-3
LABSC02 LG002G2 RXOTRX-3-3 RXOTG-3
LABSC02 LG002G3 RXOTRX-3-4 RXOTG-3
.
.
.
LABSC02 LG061D3 RXOTRX-46-0 RXOTG-46
LABSC02 LG061D3 RXOTRX-46-1 RXOTG-46
LABSC02 LG061D3 RXOTRX-46-2 RXOTG-46
LABSC02 LG061D3 RXOTRX-46-3 RXOTG-46
LABSC02 LG061D3 RXOTRX-46-4 RXOTG-46
LABSC02 LG061D3 RXOTRX-46-5 RXOTG-46


, i have already try with this script... but the problem is I dont know how to cut a part of last field..

for i in LABSC02
do
nawk '
BEGIN {
}
/RXOTRX/ {

if ($1~/RXOTRX/) {TRX="RXOTG"substr($1,7)}

}
/CONC/ {
if ($0~/ALL/) {print "'"$i"'",$2,$1,TRX};
}' /rxmop$i


.... i dont know how to make variable on "TRX"a..

thk alot for kind help

Regards,

Levi
 
You may try to replace this:
{TRX="RXOTG"substr($1,7)}
By this:
{split($1,a,"-");TRX="RXOTG-"a[2]}

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Perfect......
thx a much ..

Regards,
levi
 
its works perfectly...
and I cdontinue with end of script...
but I still have other problem to replace the last field...
I have two files, and I try to join them with replacing a last field from file1 with second field of file2...
file1
------------------------------------
LABSC02 LG005G1 RXOTRX-11-0 RXOTG-11
LABSC02 LG005G1 RXOTRX-11-1 RXOTG-11
LABSC02 LG005G2 RXOTRX-11-2 RXOTG-11
LABSC02 LG005G2 RXOTRX-11-3 RXOTG-11
LABSC02 LG005G3 RXOTRX-11-4 RXOTG-11
LABSC02 LG005G3 RXOTRX-11-5 RXOTG-11
LABSC02 LG005D2 RXOTRX-12-0 RXOTG-12
LABSC02 LG005D2 RXOTRX-12-1 RXOTG-12
LABSC02 LG005D2 RXOTRX-12-2 RXOTG-12
LABSC02 LG005D2 RXOTRX-12-3 RXOTG-12
LABSC02 LG005D2 RXOTRX-12-4 RXOTG-12
LABSC02 LG005D2 RXOTRX-12-5 RXOTG-12
LABSC02 LG137G1 RXOTRX-13-0 RXOTG-13
LABSC02 LG137G1 RXOTRX-13-1 RXOTG-13
LABSC02 LG137G2 RXOTRX-13-2 RXOTG-13
LABSC02 LG137G2 RXOTRX-13-3 RXOTG-13
LABSC02 LG137G3 RXOTRX-13-4 RXOTG-13
LABSC02 LG137G3 RXOTRX-13-5 RXOTG-13

file2
-------------------------------------

RXOTG-11 005_GRA_APAPA
RXOTG-12 005_GRA_APAPA
RXOTG-13 137_EXQ_PLAZA
RXOTG-15 185_SILVERBIRD
RXOTG-16 164_FCMB
RXOTG-17 075_ONIKAN
RXOTG-18 128_SANYA_SURL
RXOTG-19 593_APAPA
RXOTG-20 171_RACECOURSE
RXOTG-21 112_ADEKUNLE
RXOTG-22 819_NEW_SITE
RXOTG-28 450_KEFFI
RXOTG-29 598_APAPA_NEW
RXOTG-30 000_AMUKOKO
RXOTG-33 155_BOURDILLON

.. its look like simple.. but i have no how to do it..
thank again.

Regard

Levi
 
Something like this ?
nawk '
NR==FNR { a[$1]=$2; next }
{ print $1,$2,$3,a[$4] }
' file2 file1 > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 

I' tried a long a night... but it's could be done.
and u need just 4 line . u r magic 2 me...:)

thx a much...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top