?
Solved

linux awk "colum output line number"

Posted on 2008-10-15
4
Medium Priority
?
486 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 500 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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

764 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