Jared
November 29, 2012, 11:08am
1
Hi all,
i am trying to use below command to see the output of hardware inventory, but i only see 2 first line no output of the command.
awk '/Hardware/ {print $0}' XXX_result.txt
Hardware inventory:
Hardware inventory:
any idea how to see whatever is under hardware inventory.
i will really appreciate your help!
jared
Yoda
November 29, 2012, 11:20am
2
Can you please post the content of XXX_result.txt and also post the desired output you want from this file?
vbe
November 29, 2012, 11:22am
3
There is maybe nothing more...
your question is not clear, r u trying to to search string hardware in given input file XXX_result.txt ? or just want to display everything in file XXX_result.txt
?
Jared
November 29, 2012, 11:27am
5
i like to see output under hardware inventory which is like below...but you can see it only shows Hardware inventory line and thats it!
Item Version Part number Serial number Description
Chassis D3636 M320
Midplane REV 08 710-009120 TS0977 M320 Midplane
FPM GBUS REV 05 710-005928 XW5987 M320 Board
FPM Display REV 05 710-009351 XS5720 M320 FPM Display
CIP REV 05 710-005926 XW6402 M320 CIP
PEM 0 Rev 08 740-009148 VK57595 DC Power Entry Module
PEM 1 Rev 08 740-009148 VK57527 DC Power Entry Module
PEM 2 Rev 08 740-009148 VK57533 DC Power Entry Module
PEM 3 Rev 08 740-009148 VK57532 DC Power Entry Module
Routing Engine 0 REV 09 740-014082 9009041642 RE-A-2000
Yoda
November 29, 2012, 11:41am
6
Jared, please post your data samples in code tags.
By the way I don't see string: Hardware anywhere in the data sample you posted. So if you search for string: Hardware using awk, it will print only that particular line.
Jared
November 29, 2012, 11:43am
7
so can you tell me if this is even posisble how to see line below hardware uisng awk?
Yoda
November 29, 2012, 11:48am
8
Yes, this is possible. If you want just the next line, you can use getline, E.g.
# cat infile
Hardware
Line no: 1
Line no: 2
Line no: 3
# awk '/Hardware/ { print; getline; print; } ' infile
Hardware
Line no: 1
But if you want a range of line to be printed, then you have to specify that.
Jared
November 29, 2012, 12:04pm
9
Hardware inventory:
Item Version Part number Serial number Description
Chassis D3636 M320
Midplane REV 08 710-009120 TS0977 M320 Midplane
FPM GBUS REV 05 710-005928 XW5987 M320 Board
FPM Display REV 05 710-009351 XS5720 M320 FPM Display
CIP REV 05 710-005926 XW6402 M320 CIP
PEM 0 Rev 08 740-009148 VK57595 DC Power Entry Module
PEM 1 Rev 08 740-009148 VK57527 DC Power Entry Module
Scott
November 29, 2012, 12:13pm
10
Jared.
Please watch this video on how to use code tags.
The code tag button has changed and looks different in the video, but it's in the same place, next to the quote tag:
The code tag button now looks like:
And then reread the rules you agreed to when you registered, and then I will unlock your account.
RULES OF THE UNIX AND LINUX FORUMS
(1) No flames, shouting (all caps), sarcasm, bullying, profanity or arrogant posts.
(2) No negative comments about others or impolite remarks. Be patient.
(3) Refrain from idle chatter that does not contribute to the knowledge base. This does not apply to the forums in The Unix Lounge which are for off-topic discussions.
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post or send a private message where your goal is to get an answer more quickly.
(5) Search the forums database with your keywords before asking.
(6) Do not post classroom or homework problems.
(7) No job postings from headhunters or recruiters except in The Unix Forums Job Board. See How to Post to The UNIX Forums Job Board for information on using the Job Board.
(8) No BSD vs. Linux vs. Windows or similar threads.
(9) Edit your posts if you see spelling or grammar errors (don't write in cyberchat or cyberpunk style). English only.
(10) Don't post your email address and ask for an email reply. Don't send a private message with a technical question. The forums are for the benefit of all, so all Q&A should take place in the forums.
(11) Post questions with descriptive subjects. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".
(12) These are not hacker boards so hacker related posts will be promptly deleted or moderated.
(13) The forum administrators reserve the right to prune, move or edit posts that do not adhere to the rules or are technically inaccurate.
(14) The forum administrators reserve the right to remove users or change their posting status to read only without notice if any rules are not followed.
(15) No smoking in the forums.
Thank you.
Jared
November 29, 2012, 2:46pm
11
thanks and it did solve part of my problem:) can you suggest how to specify line in awk..i cant seem to find it , played around for hrs but not getting desrired result.
awk '/Hardware/ {print; getline;print; } ' xxx.txt
thanks!
Scott
November 29, 2012, 2:51pm
12
I must just be imagining it.