Sponsored Content
Full Discussion: search & select text
Top Forums Shell Programming and Scripting search & select text Post 302482586 by Franklin52 on Wednesday 22nd of December 2010 03:29:46 AM
Old 12-22-2010
Quote:
Originally Posted by gc_sw
hi Franklin52;

your solution has unfortunately given wrong lines. Smilie
This is what I get with the given file:
Code:
$ cat file
101221-18:45:17 192.168.1.1 1.0 PortNodeModel
=========================================================
Object Attribute Value
=========================================================
SectorPort=3 switchport 20
SectorPort=1 switchport 10
SectorPort=2 switchport 0
=========================================================
Total: 3 results
...
...
...
101221-18:45:17 192.168.2.1 1.0 PortNodeModel
=========================================================
Object Attribute Value
=========================================================
RbsLocalCell=S2C1 featureState 20
RbsLocalCell=S4C1 featureState 40
RbsLocalCell=S1C1 featureState 30
RbsLocalCell=S3C1 featureState 90
=========================================================
Total: 4 results
...
...
...
101221-18:45:17 192.168.3.1 1.0 PortNodeModel
=========================================================
Object Attribute Value
=========================================================
=========================================================
Total: 0 results
...
...
...
101221-18:45:17 192.168.4.1 1.0 PortNodeModel
=========================================================
Object Attribute Value
=========================================================
RbsLocalCell=S3C1 maxNumUsers 16
RbsLocalCell=S4C1 maxNumUsers 16
=========================================================
Total: 2 results
$
$
$ awk 'NF==4{print s $2;s=RS} /^Obj/{f=1;getline;next} /^=/{f=0}f' file
192.168.1.1
SectorPort=3 switchport 20
SectorPort=1 switchport 10
SectorPort=2 switchport 0

192.168.2.1
RbsLocalCell=S2C1 featureState 20
RbsLocalCell=S4C1 featureState 40
RbsLocalCell=S1C1 featureState 30
RbsLocalCell=S3C1 featureState 90

192.168.3.1

192.168.4.1
RbsLocalCell=S3C1 maxNumUsers 16
RbsLocalCell=S4C1 maxNumUsers 16

Am I missing something?
This User Gave Thanks to Franklin52 For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Select records based on search criteria on first column

Hi All, I need to select only those records having a non zero record in the first column of a comma delimited file. Suppose my input file is having data like: "0","01/08/2005 07:11:15",1,1,"Created",,"01/08/2005" "0","01/08/2005 07:12:40",1,1,"Created",,"01/08/2005"... (2 Replies)
Discussion started by: shashi_kiran_v
2 Replies

2. Shell Programming and Scripting

Advanced Search & Delete Text File

I have a file in which email messages are stored in. Every email is separated by by a ^Z character (Control-Z). I need to extract all emails after the 65,00th one to another file and delete them from the original file. Any suggests on accomplishing this? (2 Replies)
Discussion started by: maxcell
2 Replies

3. Shell Programming and Scripting

How do I search first&second string & copy all content between them to other file?

Hi All, How do I search first string & second string and copy all content between them from one file to another file? Please help me.. Thanks In Advance. Regards, Pankaj (12 Replies)
Discussion started by: pankajp
12 Replies

4. UNIX for Dummies Questions & Answers

Search for & edit rows & columns in data file and pipe

Dear unix gurus, I have a data file with header information about a subject and also 3 columns of n rows of data on various items he owns. The data file looks something like this: adam peter blah blah blah blah blah blah car 01 30 200 02 31 400 03 57 121 .. .. .. .. .. .. n y... (8 Replies)
Discussion started by: tintin72
8 Replies

5. Shell Programming and Scripting

regex to remove text before&&after comma chars

Hi, all: I have a question about "cleaning up" a huge file with regular expression(s) and sed: The init file goes like this: block1,blah-blah-blah-blah,numseries1,numseries2,numseries3,numseries4 block2,blah-blah-blah-blah-blah,numseries,numseries2,numseries3,numseries4 ...... (3 Replies)
Discussion started by: yomaya
3 Replies

6. UNIX for Dummies Questions & Answers

select nth file & range of files

Two related questions; 1. how do i select the nth file in a directory? 2. how do i select a range of files, say 2nd-5th? I have done the following but I don't think the solution is a neat one. Query 1: select nth file - say 3rd file; #!/bin/bash touch foo1 foo2 foo3 foo4 foo5 foo6... (1 Reply)
Discussion started by: Muhammad Rahiz
1 Replies

7. Shell Programming and Scripting

Search & Replacing text within a file

Hi all! I'm a newbie and I'm writing a script which will ask a user for data to search. I will then search for this data using grep and displaying this data back to the screen for the user to see. The user will then enter new data to replace the data searched. Now how do I replace this data... (4 Replies)
Discussion started by: macastor
4 Replies

8. Shell Programming and Scripting

awk + gsub to search multiple input values & replace with located string + extra text

Hi all. I have the following command that is successfully searching for any one of the strings on all lines of a file and replacing it with the instructed value. cat inputFile | awk '{gsub(/aaa|bbb|ccc|ddd/,"1234")}1' > outputFile This does in fact replace any occurrence of aaa, bbb,... (2 Replies)
Discussion started by: dazhoop
2 Replies

9. Shell Programming and Scripting

How to select the shortest path in grep search?

Hi, How can I display only one shortest path (A/B/configure)? $ grep configure file.txt A/B/configure A/B/C/configure A/B/C/D/configure Thank you. (9 Replies)
Discussion started by: hce
9 Replies

10. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies
Graphics::Primitive::Insets(3pm)			User Contributed Perl Documentation			  Graphics::Primitive::Insets(3pm)

NAME
Graphics::Primitive::Insets - Space between things DESCRIPTION
Graphics::Primitive::Insets represents the amount of space that surrounds something. This object can be used to represent either padding or margins (in the CSS sense, one being inside the bounding box, the other being outside) SYNOPSIS
use Graphics::Primitive::Insets; my $insets = Graphics::Primitive::Insets->new({ top => 5, bottom => 5, left => 5, right => 5 }); METHODS
Constructor new Creates a new Graphics::Primitive::Insets. Instance Methods as_array Return these insets as an array in the form of top, right, bottom and left. bottom Set/Get the inset from the bottom. equal_to Determine if these Insets are equal to another. left Set/Get the inset from the left. right Set/Get the inset from the right. top Set/Get the inset from the top. zero Sets all the insets (top, left, bottom, right) to 0. AUTHOR
Cory Watson, "<gphat@cpan.org>" SEE ALSO
perl(1) COPYRIGHT &; LICENSE Copyright 2008-2010 by Cory G Watson. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-08-21 Graphics::Primitive::Insets(3pm)
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy