Sponsored Content
Top Forums Shell Programming and Scripting Check Character matching from pos 7-15 to pos 211-219 if True then replace 211-219 with spaces Post 302709451 by Don Cragun on Wednesday 3rd of October 2012 09:00:09 AM
Old 10-03-2012
Quote:
Originally Posted by lancesunny
Script for if characters from positions 7-15 are matching with characters from position 211-219 then replace all char from 211-219 with 9 space.
Total length of record is 413.

Before:
RR 201 123456789 00599 0001230111 +00000000123 XXX 100111......123456789 ..............................................................................1
SS 201 00456 00599 0001230111 +00000000123 XXX 100222......12345..............................................................................2
TT 201 234567890 00599 0001230111 +00000000123 ABC 100333......234567890 ..............................................................................3

Hoping for After:
RR 201 123456789 00599 0001230111 +00000000123 XXX 100111...... ..............................................................................1
SS 201 00456 00599 0001230111 +00000000123 XXX 100222......12345..............................................................................2
TT 201 234567890 00599 0001230111 +00000000123 ABC 100333...... ..............................................................................3

where
1st Record position 7-15 & 211-219 Value=123456789 are matching and therefore we need to replace position 211-219 with 9 space characters
1st Record position 7-15 & 211-219 Value=234567890 are matching and therefore we need to replace position 211-219 with 9 space characters.

Any help on this will be appreciated.
Thanks in advance.
Please use code tags when showing input and output strings. You say that the total record length of each of your input and output records is 413, but the three input records you have given us contain 152, 143, and 152 bytes, respectively (not counting the terminating <newline> character) and each of your three output records contain 143 bytes.

You also give two conflicting descriptions of what is in the 1st record.

Making a guess at what your input really looks like, the following may work:
Code:
awk '{if(length() > 220 && substr($0,7,9) == substr($0,211,9))
                printf("%s         %s\n", substr($0,1,210), substr($0,220))
        else    print}' input

 

3 More Discussions You Might Find Interesting

1. What is on Your Mind?

This Weeks Lottery - Jackpot Now 219,500 Bits

If you want to win some Bits, the jackpot for tomorrow's drawing is up to 219,500 Bits Lottery tickets are only 100 Bits :D (0 Replies)
Discussion started by: Neo
0 Replies

2. Homework & Coursework Questions

POS 420 Week 4 IA

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: <LI style="MARGIN: 0in 0in 0pt; mso-list: l0 level1 lfo1; tab-stops: list .5in" class=MsoNormal>In your week4... (0 Replies)
Discussion started by: smiley76112
0 Replies

3. Shell Programming and Scripting

if characters from positions 7-15 are matching 219 then replace al

Script for if characters from positions 7-15 are matching with characters from position 211-219 then replace all char from 211-219 with 9 space. Total length of record is 420. Here is the specification of the data in file. Position Field Data Type... (2 Replies)
Discussion started by: lancesunny
2 Replies
ISO_8859-14(7)						     Linux Programmer's Manual						    ISO_8859-14(7)

NAME
iso_8859-14 - the ISO 8859-14 character set encoded in octal, decimal, and hexadecimal DESCRIPTION
The ISO 8859 standard includes several 8-bit extensions to the ASCII character set (also known as ISO 646-IRV). ISO 8859-14 encodes the characters used in Celtic languages. ISO 8859 Alphabets The full set of ISO 8859 alphabets includes: ISO 8859-1 West European languages (Latin-1) ISO 8859-2 Central and East European languages (Latin-2) ISO 8859-3 Southeast European and miscellaneous languages (Latin-3) ISO 8859-4 Scandinavian/Baltic languages (Latin-4) ISO 8859-5 Latin/Cyrillic ISO 8859-6 Latin/Arabic ISO 8859-7 Latin/Greek ISO 8859-8 Latin/Hebrew ISO 8859-9 Latin-1 modification for Turkish (Latin-5) ISO 8859-10 Lappish/Nordic/Eskimo languages (Latin-6) ISO 8859-11 Latin/Thai ISO 8859-13 Baltic Rim languages (Latin-7) ISO 8859-14 Celtic (Latin-8) ISO 8859-15 West European languages (Latin-9) ISO 8859-16 Romanian (Latin-10) ISO 8859-14 Characters The following table displays the characters in ISO 8859-14, which are printable and unlisted in the ascii(7) manual page. The fourth col- umn will only show the proper glyphs in an environment configured for ISO 8859-14. Oct Dec Hex Char Description ---------------------------------------------------------------- 240 160 a0 NO-BREAK SPACE 241 161 a1 LATIN CAPITAL LETTER B WITH DOT ABOVE 242 162 a2 LATIN SMALL LETTER B WITH DOT ABOVE 243 163 a3 L POUND SIGN 244 164 a4 LATIN CAPITAL LETTER C WITH DOT ABOVE 245 165 a5 LATIN SMALL LETTER C WITH DOT ABOVE 246 166 a6 LATIN CAPITAL LETTER D WITH DOT ABOVE 247 167 a7 S SECTION SIGN 250 168 a8 LATIN CAPITAL LETTER W WITH GRAVE 251 169 a9 (C) COPYRIGHT SIGN 252 170 aa LATIN CAPITAL LETTER W WITH ACUTE 253 171 ab LATIN SMALL LETTER D WITH DOT ABOVE 254 172 ac LATIN CAPITAL LETTER Y WITH GRAVE 255 173 ad SOFT HYPHEN 256 174 ae (R) REGISTERED SIGN 257 175 af LATIN CAPITAL LETTER Y WITH DIAERESIS 260 176 b0 LATIN CAPITAL LETTER F WITH DOT ABOVE 261 177 b1 LATIN SMALL LETTER F WITH DOT ABOVE 262 178 b2 LATIN CAPITAL LETTER G WITH DOT ABOVE 263 179 b3 LATIN SMALL LETTER G WITH DOT ABOVE 264 180 b4 LATIN CAPITAL LETTER M WITH DOT ABOVE 265 181 b5 LATIN SMALL LETTER M WITH DOT ABOVE 266 182 b6 9| PILCROW SIGN 267 183 b7 LATIN CAPITAL LETTER P WITH DOT ABOVE 270 184 b8 LATIN SMALL LETTER W WITH GRAVE 271 185 b9 LATIN SMALL LETTER P WITH DOT ABOVE 272 186 ba LATIN SMALL LETTER W WITH ACUTE 273 187 bb LATIN CAPITAL LETTER S WITH DOT ABOVE 274 188 bc LATIN SMALL LETTER Y WITH GRAVE 275 189 bd LATIN CAPITAL LETTER W WITH DIAERESIS 276 190 be LATIN SMALL LETTER W WITH DIAERESIS 277 191 bf LATIN SMALL LETTER S WITH DOT ABOVE 300 192 c0 A LATIN CAPITAL LETTER A WITH GRAVE 301 193 c1 A LATIN CAPITAL LETTER A WITH ACUTE 302 194 c2 A LATIN CAPITAL LETTER A WITH CIRCUMFLEX 303 195 c3 A LATIN CAPITAL LETTER A WITH TILDE 304 196 c4 A LATIN CAPITAL LETTER A WITH DIAERESIS 305 197 c5 A LATIN CAPITAL LETTER A WITH RING ABOVE 306 198 c6 AE LATIN CAPITAL LETTER AE 307 199 c7 C LATIN CAPITAL LETTER C WITH CEDILLA 310 200 c8 E LATIN CAPITAL LETTER E WITH GRAVE 311 201 c9 E LATIN CAPITAL LETTER E WITH ACUTE 312 202 ca E LATIN CAPITAL LETTER E WITH CIRCUMFLEX 313 203 cb E LATIN CAPITAL LETTER E WITH DIAERESIS 314 204 cc I LATIN CAPITAL LETTER I WITH GRAVE 315 205 cd I LATIN CAPITAL LETTER I WITH ACUTE 316 206 ce I LATIN CAPITAL LETTER I WITH CIRCUMFLEX 317 207 cf I LATIN CAPITAL LETTER I WITH DIAERESIS 320 208 d0 LATIN CAPITAL LETTER W WITH CIRCUMFLEX 321 209 d1 N LATIN CAPITAL LETTER N WITH TILDE 322 210 d2 O LATIN CAPITAL LETTER O WITH GRAVE 323 211 d3 O LATIN CAPITAL LETTER O WITH ACUTE 324 212 d4 O LATIN CAPITAL LETTER O WITH CIRCUMFLEX 325 213 d5 O LATIN CAPITAL LETTER O WITH TILDE 326 214 d6 O LATIN CAPITAL LETTER O WITH DIAERESIS 327 215 d7 LATIN CAPITAL LETTER T WITH DOT ABOVE 330 216 d8 O LATIN CAPITAL LETTER O WITH STROKE 331 217 d9 U LATIN CAPITAL LETTER U WITH GRAVE 332 218 da U LATIN CAPITAL LETTER U WITH ACUTE 333 219 db U LATIN CAPITAL LETTER U WITH CIRCUMFLEX 334 219 dc U LATIN CAPITAL LETTER U WITH DIAERESIS 335 220 dd Y LATIN CAPITAL LETTER Y WITH ACUTE 336 221 de LATIN CAPITAL LETTER Y WITH CIRCUMFLEX 337 222 df B LATIN SMALL LETTER SHARP S 340 223 e0 a LATIN SMALL LETTER A WITH GRAVE 341 224 e1 a LATIN SMALL LETTER A WITH ACUTE 342 225 e2 a LATIN SMALL LETTER A WITH CIRCUMFLEX 343 226 e3 a LATIN SMALL LETTER A WITH TILDE 344 227 e4 a LATIN SMALL LETTER A WITH DIAERESIS 345 228 e5 a LATIN SMALL LETTER A WITH RING ABOVE 346 229 e6 ae LATIN SMALL LETTER AE 347 230 e7 c LATIN SMALL LETTER C WITH CEDILLA 350 231 e8 e LATIN SMALL LETTER E WITH GRAVE 351 232 e9 e LATIN SMALL LETTER E WITH ACUTE 352 233 ea e LATIN SMALL LETTER E WITH CIRCUMFLEX 353 234 eb e LATIN SMALL LETTER E WITH DIAERESIS 354 235 ec i LATIN SMALL LETTER I WITH GRAVE 355 236 ed i LATIN SMALL LETTER I WITH ACUTE 356 237 ee i LATIN SMALL LETTER I WITH CIRCUMFLEX 357 238 ef i LATIN SMALL LETTER I WITH DIAERESIS 360 239 f0 LATIN SMALL LETTER W WITH CIRCUMFLEX 361 240 f1 n LATIN SMALL LETTER N WITH TILDE 362 241 f2 o LATIN SMALL LETTER O WITH GRAVE 363 242 f3 o LATIN SMALL LETTER O WITH ACUTE 364 243 f4 o LATIN SMALL LETTER O WITH CIRCUMFLEX 365 244 f5 o LATIN SMALL LETTER O WITH TILDE 366 245 f6 o LATIN SMALL LETTER O WITH DIAERESIS 367 246 f7 LATIN SMALL LETTER T WITH DOT ABOVE 370 247 f8 o LATIN SMALL LETTER O WITH STROKE 371 248 f9 u LATIN SMALL LETTER U WITH GRAVE 372 249 fa u LATIN SMALL LETTER U WITH ACUTE 373 250 fb u LATIN SMALL LETTER U WITH CIRCUMFLEX 374 251 fc u LATIN SMALL LETTER U WITH DIAERESIS 375 252 fd y LATIN SMALL LETTER Y WITH ACUTE 376 253 fe LATIN SMALL LETTER Y WITH CIRCUMFLEX 377 254 ff y LATIN SMALL LETTER Y WITH DIAERESIS NOTES
ISO 8859-14 is also known as Latin-8. SEE ALSO
ascii(7) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-01-15 ISO_8859-14(7)
All times are GMT -4. The time now is 10:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy