Solved

linux awk "colum output line number"

Posted on 2008-10-15
4
475 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

910 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

21 Experts available now in Live!

Get 1:1 Help Now