Solved

linux awk "colum output line number"

Posted on 2008-10-15
4
483 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
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…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

688 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