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
# 8  
Old 11-28-2012
You can use
Code:
awk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2000 a=45 s="Hardware inventory" file

b=before
a=after

thanks to Franklin52 for this.

PS Turn of caps look when typing.
# 9  
Old 11-28-2012
i tried your suggestion dos2unix and then ran the cmd awk with same result. i am still not able to see the desired output under hardware inventory.
any suggestion.

dos2unix wor3e01_result.txt
Code:
$ awk '{ if ( $0 ~ "^Hardware inventory" ) { print; getline tmp; print tmp } } ' wor3e01_result.txt

Hardware inventory:
Item             Version  Part number  Serial number     Description


as you can see i expect to see something after hardware inventory but no output....i think i tmay be somethign to do with $0 but not sure..

any help will be appreciatiated...

---------- Post updated at 11:03 AM ---------- Previous update was at 10:57 AM ----------

jotne,

i tried your suggestion it did work but add some extra line on top whihc i realy dont need.. any idea

Last edited by Scott; 11-28-2012 at 12:28 PM.. Reason: Please use code tags
# 10  
Old 11-28-2012
Give example of text and I will test too see what is wrong.
# 11  
Old 11-29-2012
i should see whatever is under the hardware inventory like below...

Code:
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

---------- Post updated 11-29-12 at 07:49 AM ---------- Previous update was 11-28-12 at 11:21 AM ----------

Guys,

any suggestion how to get the remaing output from the file using awk? or sed?

Last edited by Scott; 11-28-2012 at 12:28 PM.. Reason: Which bit of "Please use code tags" don't you understand?
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