Solved

linux awk "colum output line number"

Posted on 2008-10-15
4
471 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
Comment Utility
So, what do you want the output to look like?
0
 
LVL 84

Accepted Solution

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

Author Comment

by:Ted22
Comment Utility
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
Comment Utility
That's exactly what I mean
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now