Solved

linux awk "colum output line number"

Posted on 2008-10-15
4
480 Views
Last Modified: 2013-12-06
awk '$4 ~ /XXX/{print $4}' file

(output below)
The problem is I need the output of the column to be on the same line number it was on in the input file.
I need it to line up with the other columns because it is going to be imported into a database.

XXX25S,
XXX04934212,
XXX9-27720221,
XXX9-27719221,
XXX9-27057221,
XXX9-27721221,
XXX074-01-008,
XXXLW1185-2-6-00,
0
Comment
Question by:Ted22
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 22725688
So, what do you want the output to look like?
0
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 22725760
Is this what you mean?
awk '$4 ~ /XXX/{print $4; next}{print ""}'
0
 
LVL 1

Author Comment

by:Ted22
ID: 22725766
I want the output to be on the same line numbers that they were on in the input file below.



XXXPARTNUM
XXXF1232D, 88001, O
XXX8448462, 19204, V
XXXF1232C, 88001, O
XXX12003092, 19204, V
XXXF1230D, 88001, O
XXX11636325, 19204, V
XXX9388631, 19200, O
XXX1404289REVD, 10001, O
XXX
XXX
XXX123abcd, 88001, O
XXX
XXX
XXX
XXX278423PC20, 10001, V
XXX81798571, 4J007, O XXX25S, 61908, V
XXX
XXX
XXX3590 7518, 27085, O XXXFE-RR1, 91929, R
XXXSG3796, 10001, O
XXX2498541-1, 10001, V
XXX1370002941279, 06097, V
XXX9-27721, 0BY83, V XXX04934212, 4J007, O
XXX5HM92, 25795, O XXX9-27720221, 0BY83, V
XXX5HM91, 25795, O XXX9-27719221, 0BY83, V
XXX5HM90, 25795, O XXX9-27057221, 0BY83, V
XXX5HM93, 25795, O XXX9-27721221, 0BY83, V
XXX
XXX72436, 88001, O
XXX
XXX212-060-791-1, 97499, V
XXX4F72217-101B, 98897, O
XXX68A327154-2001, 76301, V
XXX
XXXCG408G0, 81992, V XXX074-01-008, 81992, V
XXXSV5738, 16177, O
XXX88612-1, 77646, V
XXX74A585762-2001, 76301, V
XXX68A323012-2013, 76301, V
XXX8936595-03, 98752, V
XXX75A320818-2066, 76301, V
XXX5-51298-21, 81205, V
XXXSV5738, 16177, O
XXXF297144, K1987, V
XXX
XXX
XXX
XXX4G53094-101B, 98897, O
XXX4493740, 18355, O
XXX
XXXNAS322C22-0260, 80205, V
XXXLW1185-2-6-00, 62060, O XXXLW1185-2-6-00, 83014, V
XXX
XXX740168-3, 73030, O
XXX181700-2-1, 70210, O
XXX3862T17, 3A054, V
XXXCV15-908642-3, 80378, O
XXX1208665-102, 98897, O
XXX
XXX
XXX65503-00121-107, 78286, V
XXX
XXX71562, 88001, O
XXX65902-01008-101, 78286, O
XXX
XXX209-070-272-23, 97499, V
XXX17P9B3124-35, 88277, O
XXX4302-43, 97902, V
XXXLSZ52, 89939, V
XXX
XXX
XXX
0
 
LVL 1

Author Closing Comment

by:Ted22
ID: 31506495
That's exactly what I mean
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AWS ELB 5 95
CentOS 7 Linux for HP DL380 G4 32Bits 7 45
Moving from Mcrypt to OpenSSL 18 45
Samba 4, Users Permission, 5 44
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question