Sponsored Content
Top Forums Shell Programming and Scripting Variable in not resolving in sed Post 303000147 by Mannu2525 on Wednesday 5th of July 2017 07:36:42 AM
Old 07-05-2017
Variable in not resolving in sed

I'm trying to search the 2 pattern in consecutive lines and print them but my variables are not resolving in sed (using bash shell) -

Code:
# cat testfile2.txt
Fixing Storage Locations to remove extra slash;
Fixing Storage Locations to remove extra slash;
Fixing Storage Locations to remove extra slash;
Fixing Storage Locations to remove extra slash;
Fixing Storage Locations to remove extra slash;
Fixing Storage Locations to remove extra slash; we have 0 locations in the database
Catalog OID generator updated based on GLOBAL tier catalog"
Catalog OID generator updated based on GLOBAL tier catalog"


# sed '$!N;/extra.*\n.*Catalog/p;D' testfile2.txt
Fixing Storage Locations to remove extra slash; we have 0 locations in the database
Catalog OID generator updated based on GLOBAL tier catalog"


# message1=extra
# message2=Catalog
# echo $message1
extra
# echo $message2
Catalog
# sed '$!N;/$message1.*\n.*$message2/p;D' testfile2.txt

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

DNS not resolving

I have configured my solaris 9 box to obtain a IP from the DHCP server which is on windows, I have also set up the DNS with domain name and name servers under /etc/resolv.conf I can ping a ip address I just cant seem to ping hostnames, theres probaly something im not doing. I have looked through... (9 Replies)
Discussion started by: Mr Pink
9 Replies

2. UNIX for Dummies Questions & Answers

Need help in resolving Compilation error

state_field state_abvr = { "AL","ALABAMA", "AK","ALASKA", "AZ","ARIZONA", "AR","ARKANSAS", "CA","CALIFORNIA", "CO","COLORADO", "CT","CONNECTICUT", "DE","DELAWARE", "DC","DISTRICT-OF-COLUMBIA", "FL","FLORIDA", "GA","GEORGIA", "HI","HAWAII", "ID","IDAHO", "IL","ILLINOIS",... (1 Reply)
Discussion started by: jagan_kalluri
1 Replies

3. Shell Programming and Scripting

Sed variable substitution when variable constructed of a directory path

Hello, i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem. my var1 is a string constructed like this: filename1 filerev1 filepath1 my var2 is another string constructed like this: filename2 filerev2 filepath2 when i do... (2 Replies)
Discussion started by: alrinno
2 Replies

4. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

5. Shell Programming and Scripting

Resolving Var to its contents

Hello everyone.... I am trying to dinamically create variable names and do resolution of this vars contents. After that is done I want to use (via a function call) the var and its contents by referring to it via the variable name. I am having a hard time achieving this .... can you help ? ... (5 Replies)
Discussion started by: gio001
5 Replies

6. Shell Programming and Scripting

Expand an environment variable in sed, when the variable contains a slash

I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash". sed -e 's/<HOME_DIRECTORY>/'$HOME'/'This gives me the following error: sed: -e expression #1, char 21: unknown option to `s'Obviously this is... (2 Replies)
Discussion started by: Ilja
2 Replies

7. Red Hat

How to pass value of pwd as variable in SED to replace variable in a script file

Hi all, Hereby wish to have your advise for below: Main concept is I intend to get current directory of my script file. This script file will be copied to /etc/init.d. A string in this copy will be replaced with current directory value. Below is original script file: ... (6 Replies)
Discussion started by: cielle
6 Replies

8. Shell Programming and Scripting

Resolving the environment variable from a file

Hi, I an having some environment variables exported and the variable name is present in the file. But its not resolving with following commands. Can someone throw some light. db $ grep -v "^#" TD_FWK_NUCLEUS.dbc | grep -v "^$" | xargs -i echo {} wb_bin: ${TD_FWK_NUCLEUS_DBC_WB_BIN_TAG} I... (3 Replies)
Discussion started by: Mohammed Rafi
3 Replies

9. UNIX for Beginners Questions & Answers

Help for resolving Unexpected EOF while assigning value to variable

#!/bin/sh . /opt/ora/oracle/db/tech_st/11.2.3/PROD_proddb.env sqlplus -s "username/password" << EOF no='sqlplus -s username/password<<EOF set heading off set feedback off Select pt.user_concurrent_program_name report_name , OUTFILE_NAME report_path FROm apps.fnd_concurrent_programs_tl... (12 Replies)
Discussion started by: usman_oracle
12 Replies

10. UNIX for Beginners Questions & Answers

Resolving the UNIX path variable

Friends, I trying to get the unix path fro a config file. There are 100 + path variables defined in the master_config.sh. Like this ; app_dir=/project/emp abc_dir=${app_dir}/abc/app abc_common=${abc_dir}/common abc_common_base=${abc_common}/base... (2 Replies)
Discussion started by: arunv123
2 Replies
XML::Catalog(3) 					User Contributed Perl Documentation					   XML::Catalog(3)

NAME
XML::Catalog - Resolve public identifiers and remap system identifiers SYNOPSIS
use XML::Catalog; my $catalog=XML::Catalog->new('/xml/catalog.cat'); $catalog->add('http://www.w3.org/xcatalog/mastercat.xml'); my $sysid=$catalog->resolve_public('-//John Cowan//LOC Diacritics'); my $newsysid=$catalog->remap_system('http://www.w3.org'); $parser->setHandlers(ExternEnt=>$catalog->get_handler($parser)); Oasis Example $ perl -e 'use XML::Catalog; $pubid = q|-//OASIS//DTD DocBook XML V4.5//EN|; my $catalog=XML::Catalog->new("/etc/xml/catalog"); print $catalog->resolve_public($pubid), " ";' file:///usr/share/sgml/docbook/xml-dtd-4.5-1.0-51.el6/docbookx.dtd DESCRIPTION
This module implements draft 0.4 of John Cowan's XML Catalog (formerly known as XCatalog) proposal (<http://www.ccil.org/~cowan/XML/XCatalog.html>). Catalogs may be written in either SOCAT or XML syntax (see the proposal for syntax details); XML::Catalog will assume SOCAT syntax if the catalog is not in well-formed XML syntax. This module, as of 1.0.0, also supports Oasis XML catalogs. CONSTRUCTOR
new(URL [,URL]*) Read the catalog identified by URL and return a catalog object implementing it. If more than one URL is given, chain the additional catalogs as extensions to the catalog (they will be searched before catalogs specified by EXTEND entries). All URLs must be absolute. A URL with no protocol is treated as a filename. METHODS
add(URL [,URL]*) Chain the catalogs identified by the URL(s) to the current catalog. resolve_public(PUBID) Translate the public identifier PUBID to a system identifier. Returns undef if the identifier could not be translated. remap_system(SYSID) Remap the system identifier SYSID as specified by the catalog. Returns SYSID unchanged if no remapping was found. get_handler(PARSER) Returns a coderef to a resolver suitable for use as the ExternEnt handler for an XML::Parser object. The resolver will first attempt to resolve a public identifier if supplied, and then attempt to remap the resulting system identifier (or the original system identifier if no public identifier was supplied). It will then call the original ExternEnt handler associated with the parser object. PARSER is the parser object; it is needed as an argument in order to obtain the original handler. add_delegate($pubid, $href) TBD add_extend($href) TBD add_extend_object($cat, $group ) TBD add_map($pubid, $href) TBD add_remap($sysid, $href) TBD build($url) create new catalog object fix_base($url) TBD parse TBD parse_SOCAT($ct) TBD parse_XML($ct) TBD set_base($href) TBD BUGS
/ TODO Searching of chained catalogs is not purely depth-first (EXTEND items in a chained catalog will be searched before EXTEND items in the original catalog. Error checking leaves much to be desired. AUTHOR
Current Author: Jeff Fearn E<lt>jfearn@cpan.orgE<gt>. Former Authors: Eric Bohlman E<lt>ebohlman@netcom.comE<gt>. COPYRIGHT
Copyright (c) 1999-2000 Eric Bohlman. All rights reserved. Copyright (c) 2013 Jeff Fearn. All rights reserved. This program is free software; you can use/modify/redistribute it under the same terms as Perl itself. perl v5.16.3 2013-10-28 XML::Catalog(3)
All times are GMT -4. The time now is 10:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy