Sponsored Content
Top Forums Shell Programming and Scripting To extract certain columnns with header Post 302989327 by Riverstone on Wednesday 11th of January 2017 07:24:47 AM
Old 01-11-2017
Thank you Rudie , have partly submitted my query earlier in a hurry my actual data content as below.

Code:
1
     LIST 950C/M                         Jeffron aliff system
     MASTERS                                       ISSUE    REPORT (MONTHLY)               01JAN15      PAGE      1
0    MOVEMENT CODE  26     
0    STOCK A/C NO   1400100
0    I I C     P A R T  N U M B E R    KEYWORD      J A N     ORD NO   DOC NO DDMM INV NO / SER NO VENDOR UM     Q T Y   TOTAL VALUE
 ------------ ------------------------ -------- ------------ --------- ------ ---- --------------- ------ -- ---------- ------------
 424009024545 PEF0AM1MX2MX40MM         PLAIN PE              490117701 110024 0112 8916            280819 58      20.0        850.00
 424009020858 3M7447                   SCOTCHBR              490118901 110025 0112 SM0883          280799 29       9.0       1181.25
 424009024756 SAFETYC0NE30IN           PVC TRAF              490126001 110026 0112 1412008         280477 01      10.0        450.00
 424009022922 C0TT0NRAG                COTTON R              490105304 110027 0112 13264           280696 48     100.0       4200.00
 436003010191 ARINUS0940               SANITISI              490121901 120046 0112 D01100477       280708 52       4.0        200.00
 440101001488 8W550C3                  PRIMER S              421751301 397174 0212 1557            S22112 39       1.0        459.59
 1
     LIST 950C/M                         Jeffron aliff system
     MASTERS                                       ISSUE   ANALYSIS   REPORT (MONTHLY)               01JAN15      PAGE      2
0    MOVEMENT CODE  26     
0    STOCK A/C NO   1400100
0    I I C     P A R T  N U M B E R    KEYWORD      J A N     ORD NO   DOC NO DDMM INV NO / SER NO VENDOR UM     Q T Y   TOTAL VALUE
 ------------ ------------------------ -------- ------------ --------- ------ ---- --------------- ------ -- ---------- ------------
 440101000437 BR127                    PRIMER                421755201 397185 0512 3027490         D24170 15       2.0       1410.72
 440101000578 SIKKENSN0NSLIPGREY       SIKKENS               421752701 361076 0512 15668           S22112 15       5.0       1508.94
 424009025224 WHEELCAST0R8X2SWIVEL     WHEEL CA              490127301 110047 0512 111931          290040 01      20.0        960.00
 424009025225 SELFTAPINGSCREW112IN     SELF TAP              490127302 110048 0512 111931          290040 52       1.0         26.00
 424009020343 BRUSHBAMB002INSX6STICK   BAMBOO S              490126701 110049 0512 111896          290040 01      20.0         80.00
1
     LIST 950C/M                         Jeffron aliff system
     MASTERS                                       ISSUE   ANALYSIS   REPORT (MONTHLY)               01JAN15      PAGE      3
0    MOVEMENT CODE  26     STORING OF ORDERED MATERIAL
0    STOCK A/C NO   1400100
0    I I C     P A R T  N U M B E R    KEYWORD      J A N     ORD NO   DOC NO DDMM INV NO / SER NO VENDOR UM     Q T Y   TOTAL VALUE
 ------------ ------------------------ -------- ------------ --------- ------ ---- --------------- ------ -- ---------- ------------
 440006000061 EP0CAST1619AB            ADHESIVE              421766901 397205 1212 3029548         D24170 39       1.0        344.28
 440002000198 PR1422B2                 SEALANT               421766902 397206 1212 3029548         D24170 39       2.0        209.92
 440001000246 DUNL0PLP                 DUNLOP L              421750101 381910 1212 D01341MY1       280911 15      50.0       2350.00
 440306000045 SKDS2                    MAGNAFLU              421761201 381909 1212 18036089        290065 15     204.0       6120.00
 440202000015 ASG223KIL0               AEROSHEL              421756401 334607 1212 30854           D24170 15      33.0      10391.53
 440002000044 PS870A2                  PS870A2               421724801 397208 1212 QA213552014     S23196 39      48.0       5962.92

and my requirement is to pick header named as mentioned earlier [3 column] and all records by skipping below content.


Code:
1
     LIST 950C/M                         Jeffron aliff system
     MASTERS                                       ISSUE   ANALYSIS   REPORT (MONTHLY)               01JAN15      PAGE      2
0    MOVEMENT CODE  26     
0    STOCK A/C NO   1400100

three column header only once and from the next line all records of the file
all records which i need to pick having one space in beginning the rest.


Moderator's Comments:
Mod Comment Please use CODE tags correctly as required by forum rules!


---------- Post updated at 07:24 AM ---------- Previous update was at 06:20 AM ----------

So output should be as below

Code:
0    I I C     P A R T  N U M B E R    KEYWORD      J A N     ORD NO   DOC NO DDMM INV NO / SER NO VENDOR UM     Q T Y   TOTAL VALUE
 ------------ ------------------------ -------- ------------ --------- ------ ---- --------------- ------ -- ---------- ------------
 424009024545 PEF0AM1MX2MX40MM         PLAIN PE              490117701 110024 0112 8916            280819 58      20.0        850.00
 424009020858 3M7447                   SCOTCHBR              490118901 110025 0112 SM0883          280799 29       9.0       1181.25
 424009024756 SAFETYC0NE30IN           PVC TRAF              490126001 110026 0112 1412008         280477 01      10.0        450.00
 424009022922 C0TT0NRAG                COTTON R              490105304 110027 0112 13264           280696 48     100.0       4200.00
 436003010191 ARINUS0940               SANITISI              490121901 120046 0112 D01100477       280708 52       4.0        200.00
 440101001488 8W550C3                  PRIMER S              421751301 397174 0212 1557            S22112 39       1.0        459.59
 440101000437 BR127                    PRIMER                421755201 397185 0512 3027490         D24170 15       2.0       1410.72
 440101000578 SIKKENSN0NSLIPGREY       SIKKENS               421752701 361076 0512 15668           S22112 15       5.0       1508.94
 424009025224 WHEELCAST0R8X2SWIVEL     WHEEL CA              490127301 110047 0512 111931          290040 01      20.0        960.00
 424009025225 SELFTAPINGSCREW112IN     SELF TAP              490127302 110048 0512 111931          290040 52       1.0         26.00
 424009020343 BRUSHBAMB002INSX6STICK   BAMBOO S              490126701 110049 0512 111896          290040 01      20.0         80.00
 440006000061 EP0CAST1619AB            ADHESIVE              421766901 397205 1212 3029548         D24170 39       1.0        344.28
 440002000198 PR1422B2                 SEALANT               421766902 397206 1212 3029548         D24170 39       2.0        209.92
 440001000246 DUNL0PLP                 DUNLOP L              421750101 381910 1212 D01341MY1       280911 15      50.0       2350.00
 440306000045 SKDS2                    MAGNAFLU              421761201 381909 1212 18036089        290065 15     204.0       6120.00
 440202000015 ASG223KIL0               AEROSHEL              421756401 334607 1212 30854           D24170 15      33.0      10391.53
 440002000044 PS870A2                  PS870A2               421724801 397208 1212 QA213552014     S23196 39      48.0       5962.92


Last edited by RudiC; 01-11-2017 at 07:24 AM.. Reason: Changed ICODE to CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to extract duplicate records with associated header record

All, I have a task to search through several hundred files and extract duplicate detail records and keep them grouped with their header record. If no duplicate detail record exists, don't pull the header. For example, an input file could look like this: input.txt HA D1 D2 D2 D3 D4 D4... (17 Replies)
Discussion started by: run_eim
17 Replies

2. Shell Programming and Scripting

Extract date from file header and prefix it to all lines

Hello All, I have a file in the following format. I want to extract the date(020090930, 020090929) in the string "STPAGE020090930" and "STPAGE020090929" and prefix it to all lines below them. The output must be put into a new file. STPAGE020090930 xyzz aalc... (3 Replies)
Discussion started by: john2022
3 Replies

3. Shell Programming and Scripting

Extract header from top command output

hi, I want to extract and save the cpu(s) information from top command output, but individual cpu statistics separately on a multi-processor machine. In command line, top will show this statistics when we press the switch "1". any ideas? thanks, meharo (3 Replies)
Discussion started by: meharo
3 Replies

4. Shell Programming and Scripting

Extract specific content from data and rename its header problem asking

Input file 1: >pattern_5 GAATTCGTTCATGTAGGTTGASDASFGDSGRTYRYGHDGSDFGSDGGDSGSDGSDFGSDF ATTTAATTATGATTCATACGTCATATGTTATTATTCAATCGTATAAAATTATGTGACCTT SDFSDGSDFKSDAFLKJASLFJASKLFSJAKJFHASJKFHASJKFHASJKFHSJAKFHAW >pattern_1 AAGTCTTAAGATATCACCGTCGATTAGGTTTATACAGCTTTTGTGTTATTTAAATTTGAC... (10 Replies)
Discussion started by: patrick87
10 Replies

5. Shell Programming and Scripting

Using AWK BEGIN to extract file header info into variables

Hi Folks, I've searched for this for quite a while, but can't find any solution - hope someone can help. I have various files with standard headers. eg. <HEADER> IP: 1.2.3.4 Username: Joe Time: 12:00:00 Date: 23/05/2010 </HEADER> This is a test and this part can be any size... (6 Replies)
Discussion started by: damoske
6 Replies

6. Shell Programming and Scripting

Extract columns where header matches a given string

Hi, I'm having trouble pulling out columns where the headers match a file of key ID's I'm interested in and was looking for some help. file1.txt I Name 34 56 84 350 790 1215 1919 7606 9420 file2.txt I Name 1 1 2 2 3 3 ... 34 34... 56 56... 84 84... 350 350... M 1 A A A A... (20 Replies)
Discussion started by: flotsam
20 Replies

7. UNIX for Dummies Questions & Answers

Merge all csv files in one folder considering only 1 header row and ignoring header of all others

Friends, I need help with the following in UNIX. Merge all csv files in one folder considering only 1 header row and ignoring header of all other files. FYI - All files are in same format and contains same headers. Thank you (4 Replies)
Discussion started by: Shiny_Roy
4 Replies

8. Shell Programming and Scripting

Extract columns based on header

Hi to all, I have two files. File1 has no header, two columns: sample1 A sample2 B sample3 B sample4 C sample5 A sample6 D sample7 D File2 has a header, except for the first 3 columns (chr,start,end). "sample1" is the header for the 4th ,5th ,6th columns, "sample2" is the header... (4 Replies)
Discussion started by: aec
4 Replies

9. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies

10. Shell Programming and Scripting

Find header in a text file and prepend it to all lines until another header is found

I've been struggling with this one for quite a while and cannot seem to find a solution for this find/replace scenario. Perhaps I'm getting rusty. I have a file that contains a number of metrics (exactly 3 fields per line) from a few appliances that are collected in parallel. To identify the... (3 Replies)
Discussion started by: verdepollo
3 Replies
All times are GMT -4. The time now is 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy