Sponsored Content
Top Forums Shell Programming and Scripting Grep a part of file based on string identifiers Post 302783207 by vivek d r on Wednesday 20th of March 2013 06:15:02 AM
Old 03-20-2013
Grep a part of file based on string identifiers

consider below file contents

Code:
cat myOutputFIle.txt
8 CCM-HQE-ResourceHealthCheck:
Resource List :
No RED/UNKNOWN resource Health entries found
----------------------------------------------------------
9 CCM-TraderLogin-Status:
Number of logins: 0
----------------------------------------------------------
10 CCM HA Status:
Server:XXX.XX.XX.XX not enabled
Server Role:ACTIVE
Server State:AVAILABLE
Network State:GY_PY
----------------------------------------------------------
11 MG-DigitalPortChannel-Status:
No MG's are present hence terminating script
----------------------------------------------------------
12 MM-Operational-State:
HTML Code:
ipAddress       requestOperationalState
XX.xx.XX.XX.XX   MS_INTRAFFIC
----------------------------------------------------------


what i want to achieve is grep a string let say "CCM HA Status:" and display all the lines below it till it reaches "-----------------------------------------"

i implemented partially using sed command. .but its displaying output allong with identifiers..

Code:
[root@htmlgen]# sed -n "/CCM HA Status:/,/----------------------------------------------------------/ w tablextract2.sql" <myOutputFIle.txt
[root@ htmlgen]#
[root@duhtmlgen]# cat tablextract2.sql
10 CCM HA Status:
Server:xxx.xx.xxx.xxHA not enabled
Server Role:ACTIVE
Server State:AVAILABLE
Network State:GY_PY
----------------------------------------------------------
[root@ htmlgen]#


what the expected output is

Code:
Server:xxx.xx.xxx.xxHA not enabled
Server Role:ACTIVE
Server State:AVAILABLE
Network State:GY_PY

similarly if i search for "MM-Operational-State:" it should display below output

Code:
ipAddress       requestOperationalState
XX.xx.XX.XX.XX   MS_INTRAFFIC

any help is appreciated.. thanks

Last edited by vivek d r; 03-21-2013 at 01:27 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sort entire line based on part of the string

hey gurus, my-build1-abc my-build10-abc my-build2-abc my-build22-abc my-build3-abc basically i want to numerically sort the entire lines based on the build number. I dont zero pad the numbers because thats "how it is" ;-) sort -n won't work because it starts from the beginning. ... (10 Replies)
Discussion started by: gurpal2000
10 Replies

2. Shell Programming and Scripting

Need Awk command to get part of string based on delimeter

HI, Need awk command to get date and time alone from Input : "15:29:15 28.08.2010|SCHEDULE: Started program POSG1" Output expected : "15:29:15 28.08.2010" Please help. (9 Replies)
Discussion started by: shanneykar
9 Replies

3. Shell Programming and Scripting

Extracting few lines from a file based on identifiers dynamically

i have something like this in a file called mysqldump.sql -- -- Table structure for table `Table11` -- DROP TABLE IF EXISTS `Table11`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `Table11` ( `id` int(11) NOT NULL... (14 Replies)
Discussion started by: vivek d r
14 Replies

4. Shell Programming and Scripting

Extracting lines based on identifiers into multiple files respectively

consider the following is the contents of the file cat 11.sql drop procedure if exists hoop1 ; Delimiter $$ CREATE PROCEDURE hoop1(id int) BEGIN END $$ Delimiter ; . . . . drop procedure if exists hoop2; Delimiter $$ CREATE PROCEDURE hoop2(id int) BEGIN END $$ (8 Replies)
Discussion started by: vivek d r
8 Replies

5. Shell Programming and Scripting

Possible to grep string based on surrounding strings?

I was wondering if it was possible to grep a pattern based on the surround text. For example, if i have an input file like this: titleA titleB titlex titleC titleD titlex titleE And I want to grep "title" and save the results only if it is not followed with a "titlex". My output... (14 Replies)
Discussion started by: jl487
14 Replies

6. Shell Programming and Scripting

cut a line into different fields based on identifiers

cat fileanme.txt custom1=, custom2=, userPulseId=3005, accountPolicyId=1, custom3=, custom4=, homeLocationId=0, i need to make the fields appear in next line based on identifier (,) ie comma so output should read cat fileanme.txt custom1=, custom2=, userPulseId=3005, ... (8 Replies)
Discussion started by: vivek d r
8 Replies

7. Shell Programming and Scripting

Remove part of a file based on identifiers

here below is a part of the file cat fileName.txt NAME=APP-VA-va_mediaservices-113009-VA_MS_MEDIA_SERVER_NOT_PRESENT-S FIXED=false DATE= 2013-02-19 03:46:04.4 PRIORITY=HIGH RESOURCE NAME=ccm113 NAME=APP-DS-ds_ha-140020-databaseReplicationFailure-S FIXED=false DATE= 2013-02-19... (4 Replies)
Discussion started by: vivek d r
4 Replies

8. Shell Programming and Scripting

Match part of string in file2 based on column in file1

I have a file containing texts and indexes. I need the text between (and including ) INDEX and number "1" alone in line. I have managed this: awk '/INDEX/,/1$/{if (!/1$/)print}' file1.txt It works for all indexes. And then I have second file with years and indexes per year, one per line... (3 Replies)
Discussion started by: phoebus
3 Replies

9. Shell Programming and Scripting

How to grep the required part from the string?

Hi All, I am trying to fetch the particular content from the result of grep command. I am using ps-ef |grep engine| awk '{print $6}' above statement giving me /opt/test/user/domain/CORPTEST/application/CacheScheduler/CacheScheduler-CacheScheduler but I want (13 Replies)
Discussion started by: sharsour
13 Replies

10. Shell Programming and Scripting

Discard part of a file based on a pattern ---

I have the file: s3_T0(2) Pos "1" "2" s1_T1(2) Pos "1" "2" --- 0 0 1 0 0 1 1 1 --- 1 2 "tau0" 1 2 "h10" I want to patternmatch on --- and get only the third part i.e. 1 2 "tau0" 1 2 "h10" I wanted to start simple but even something like (5 Replies)
Discussion started by: eagle_fly
5 Replies
native::Wc(3)						User Contributed Perl Documentation					     native::Wc(3)

NAME
SVN::Wc - Subversion working copy functions SYNOPSIS
Incomplete OBJECTS
svn_wc_status_t $wcstat->entry() A svn_wc_entry_t object for the item. Can be undef if not under version control. $wcstat->text_status() An integer representing the status of the item's text. Can be one of the $SVN::Wc::Status::* constants. $wcstat->prop_status() An integer representing the status of the item's properties. Can be one of the $SVN::Wc::Status::* constants. $wcstat->locked() A boolean telling if the item is locked. A directory can be locked if a working copy update was interrupted. $wcstat->copied() A boolean telling if the item was copied. A file or directory can be copied if it's scheduled for addition-with-history (or part of a subtree that is scheduled as such). $wcstat->switched() A boolean telling if the item was switched. A file or directory can be switched if the switch command has been used. $wcstat->repos_text_status() An integer representing the status of the item's text in the repository. Can be one of the $SVN::Wc::Status::* constants. $wcstat->repos_prop_status() An integer representing the status of the item's properties in the repository. Can be one of the $SVN::Wc::Status::* constants. svn_wc_entry_t $wcent->name() Entry's name. $wcent->revision() Base revision. $wcent->url() URL in repository. $wcent->repos() Canonical repository URL. $wcent->uuid() Repository uuid. $wcent->kind() The kind of node. One of the following constants: $SVN::Node::none, $SVN::Node::file, $SVN::Node::dir, $SVN::Node::unknown. $wcent->schedule() Scheduling. One of the SVN::Wc::Schedule::* constants. $wcent->copied() In a copied state. $wcent->deleted() Deleted, but parent rev lags behind. $wcent->absent() Absent -- we know an entry of this name exists, but that's all (usually this happens because of authz restrictions) $wcent->incomplete() For THIS_DIR entry, implies whole entries file is incomplete. $wcent->copyfrom_url() Copyfrom location. $wcent->copyfrom_rev() Copyfrom revision. $wcent->conflict_old() Old version of conflicted file. $wcent->conflict_new() New version of conflicted file. $wcent->conflict_wrk() Working version of conflicted file. $wcent->prejfile() Property reject file. $wcent->text_time() Last up-to-date time for text contents (0 means no information available). $wcent->prop_time() Last up-to-date time for properties (0 means no information available). $wcent->checksum() Base-64 encoded checksum for the untranslated text base file, can be undef for backwards compatibility. $wcent->cmt_rev() Last revision this was changed. $wcent->cmt_date() Last date this was changed. $wcent->cmt_author() Last commit author of this item. CONSTANTS
SVN::Wc::Notify::Action $SVN::Wc::Notify::Action::add Adding a path to revision control. $SVN::Wc::Notify::Action::copy Copying a versioned path. $SVN::Wc::Notify::Action::delete Deleting a versioned path. $SVN::Wc::Notify::Action::restore Restoring a missing path from the pristine text-base. $SVN::Wc::Notify::Action::revert Reverting a modified path. $SVN::Wc::Notify::Action::failed_revert A revert operation has failed. $SVN::Wc::Notify::Action::resolved Resolving a conflict. $SVN::Wc::Notify::Action::skip Skipping a path. $SVN::Wc::Notify::Action::update_delete Got a delete in an update. $SVN::Wc::Notify::Action::update_add Got an add in an update. $SVN::Wc::Notify::Action::update_update Got any other action in an update. $SVN::Wc::Notify::Action::update_completed The last notification in an update (including updates of externals). $SVN::Wc::Notify::Action::update_external Updating an external module. $SVN::Wc::Notify::Action::status_completed The last notification in a status (including status on externals). $SVN::Wc::Notify::Action::status_external Running status on an external module. $SVN::Wc::Notify::Action::commit_modified Committing a modification. $SVN::Wc::Notify::Action::commit_added Committing an addition. $SVN::Wc::Notify::Action::commit_deleted Committing a deletion. $SVN::Wc::Notify::Action::commit_replaced Committing a replacement. $SVN::Wc::Notify::Action::commit_postfix_txdelta Transmitting post-fix text-delta data for a file. $SVN::Wc::Notify::Action::blame_revision Processed a single revision's blame. SVN::Wc::Notify::State $SVN::Wc::Notify::State::unknown Notifier doesn't know or isn't saying. $SVN::Wc::Notify::State::unchanged The state did not change. $SVN::Wc::Notify::State::missing The item wasn't present. $SVN::Wc::Notify::State::obstructed An unversioned item obstructed work. $SVN::Wc::Notify::State::changed Pristine state was modified. $SVN::Wc::Notify::State::merged Modified state had mods merged in. $SVN::Wc::Notify::State::conflicted Modified state got conflicting mods. SVN::Wc::Schedule $SVN::Wc::Schedule::normal Nothing special here. $SVN::Wc::Schedule::add Slated for addition. $SVN::Wc::Schedule::delete Slated for deletion. $SVN::Wc::Schedule::replace Slated for replacement (delete + add) SVN::Wc::Status $SVN::Wc::Status::none Does not exist. $SVN::Wc::Status::unversioned Is not a versioned node in this working copy. $SVN::Wc::Status::normal Exists, but uninteresting. $SVN::Wc::Status::added Is scheduled for addition. $SVN::Wc::Status::missing Under version control but missing. $SVN::Wc::Status::deleted Scheduled for deletion. $SVN::Wc::Status::replaced Was deleted and then re-added. $SVN::Wc::Status::modified Text or props have been modified. $SVN::Wc::Status::merged Local mods received repos mods. $SVN::Wc::Status::conflicted Local mods received conflicting mods. $SVN::Wc::Status::ignored A node marked as ignored. $SVN::Wc::Status::obstructed An unversioned resource is in the way of the versioned resource. $SVN::Wc::Status::external An unversioned path populated by an svn:externals property. $SVN::Wc::Status::incomplete A directory doesn't contain a complete entries list. COPYRIGHT
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. perl v5.16.3 2009-11-30 native::Wc(3)
All times are GMT -4. The time now is 12:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy