Cant see rest of the output of the file using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cant see rest of the output of the file using awk
# 1  
Old 11-27-2012
Cant see rest of the output of the file using awk

I am trying to parse through set of data from large txt file and only intersted in output below . i am using below awk command to get the output but it only shows first line , i need to see the rest of the output under hardware inventory. see below

Code:
]$ awk '{ if ( $0 ~ "^Hardware inventory" ) { print; getline tmp; print tmp } } ' wor3e01_result.txt 
Hardware inventory:
Item             Version  Part number  Serial number     Description
Hardware inventory:
Item             Version  Part number  CLEI code         FRU model number

thanks in advance!
jared

Last edited by Franklin52; 11-29-2012 at 03:48 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 11-27-2012
1>Use Code tags
2>The command is correctly giving in the way its designed
3>Unless you don't mention your output data, helping is very difficult
# 3  
Old 11-27-2012
try first:
Code:
dos2ux wor3e01_result.txt

then run the awk
# 4  
Old 11-27-2012
when i try dos2ux i get following error message.
bash: command not found

also the output i like to see is below:

Item Version Part number CLEI code FRU model number
FPM Display REV 03 710-021387 CRAFT-TXXX-S
CIP REV 06 710-002895 CIP-L-T640-S
PEM 0 Rev 02 740-026384 IPUPAC7KTB PWR-TXXX-3-80

---------- Post updated at 03:36 PM ---------- Previous update was at 03:34 PM ----------

hi what is code tag? sorry new to unixSmilie

---------- Post updated at 03:37 PM ---------- Previous update was at 03:36 PM ----------

BTW: what is code tag? new to unix guysSmilie
# 5  
Old 11-27-2012
Code tags are not a "Unix thing". They're a forum thing. You got a PM about it. And a couple of infraction points with it.
# 6  
Old 11-27-2012
try:
Code:
dos2unix wor3e01_result.txt

# 7  
Old 11-27-2012
oK COOL....I WAS ABLE TO DO WHAT I WAS TRYING TO DO VIA USING GREP....WORKS FINE...BUT DO LIKE TO KNOW IF SAME CAN BE DONE USING AWK.

Code:
grep -A45 "Hardware" XXX.txt

or

Code:
cat xxx.txt | grep -A2000 "Hardware inventory" | grep -B2000 "Hardware inventory"


Last edited by Scott; 11-27-2012 at 05:19 PM.. Reason: Code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

Awk script to run a sql and print the output to an output file

Hi All, I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file. Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies

3. Shell Programming and Scripting

[Solved] How to display only output of DBMS_OUTPUT.PUT_LINE , rest should be neglected

Hi All, I Have written a script through that i am calling sql file Sqlfile.sql set time on set timing on set echo on set head off set scan on set feedback on set serveroutput on set linesize 1000 DECLARE v_acc_no NUMBER(10); v_product_no NUMBER(10); BEGIN... (3 Replies)
Discussion started by: sujit_kashyap
3 Replies

4. Shell Programming and Scripting

Find the text in the file and delete the rest of the line.

Hi, I have one requiremnet like this. I need to find some particular string (eg.IncludeDateTime = ) in a file. And wherever it finds the string the unix script has to delete the remaining text coming after the string (ie., 'IncludeDateTime = ' ) in the same line. I tried to write this script in... (5 Replies)
Discussion started by: jannusuresh
5 Replies

5. UNIX for Dummies Questions & Answers

find string and get the rest of the line in a pipe delimited file

Hi friends, I have a file where I should search for a string and get the rest of the line but without the delimiter using awk. for example I have the series of string in a file: input_string.txt bbb ccc aaa and the mapping file looks like this. mapping.txt aaa|12 bbb|23 ccc|43... (11 Replies)
Discussion started by: kokoro
11 Replies

6. Shell Programming and Scripting

awk delete/remove rest of line on multiple search pattern

Need to remove rest of line after the equals sign on search pattern from the searchfile. Can anybody help. Couldn't find any similar example in the forum: infile: 64_1535: Delm. = 86 var, aaga 64_1535: Fran. = 57 ex. ccc 64_1639: Feb. = 26 (link). def 64_1817: mar. = 3/4. drz ... (7 Replies)
Discussion started by: sdf
7 Replies

7. Shell Programming and Scripting

Cut last 13 characters and take the rest of the file name

Hi, I would like to cut last 13 characters of a file name and take the rename the file name as follows: Input: A.DAT20110517033732 Output: A.DAT I have tried the following command and cut last 13 characters. echo A.DAT20110517033732 | awk '{print substr($0, length($0)-13)}' ... (3 Replies)
Discussion started by: pyaranoid
3 Replies

8. Shell Programming and Scripting

Parse file using awk and work in awk output

hi guys, i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 this the file raw format: Number of... (6 Replies)
Discussion started by: dagigg
6 Replies

9. Shell Programming and Scripting

Awk adding a space between integer and the rest of the field

Hi, I have a problem where some of the records I need to process have the first address field as something like "10Walpole Street" where obviously I want it to be "10 Walpole Street". I know I need to somehow separate out the integer and probably form a new string variable, but I just don't... (5 Replies)
Discussion started by: jonathanm
5 Replies

10. Shell Programming and Scripting

Want to execute rest of the script after the file is ready ...

Hi All I have a requirement like, where a file gets generated in a particular dir and once the file is ready and available then I want to execute rest of the script, because untill and unless the file exists and is available there is no use of running rest of the commands in that script. ... (5 Replies)
Discussion started by: csaha
5 Replies
Login or Register to Ask a Question