Sponsored Content
Top Forums Shell Programming and Scripting Perl/sed Escape Syntax Problem . . . Post 302923146 by LinQ on Thursday 30th of October 2014 05:18:10 PM
Old 10-30-2014
Perl/sed Escape Syntax Problem . . .

Greetings!

I've run into this before; and am having a spot of trouble trying to figure out the way that Perl would prefer the following example syntax to be formed:
Code:
#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

`sed -i 's/Hi Mom!\|Hi Dad!/Bye Everyone!/I' ./test.txt`;

Perl doesn't throw a fit; but sed simply looks at you funny and does nothing at all...

So, while there are "sleeker" ways of handling this with pure perl, this type of issue has bugged me for a bit. Any ideas as to how one might pull things together syntaxwise to make it tick over???

Smilie

Thanks for the help, and have a great day!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

possible to escape the \ character in sed?

is it possible to escape the \ character in sed? right now I'm trying to replace all occurances of \ with \\ sed \"s|test|test_replacement|g\" file1 > output; #this works fine sed \"s|\\|\\\|g\" file1 > output; #this generates the following error: sed: -e expression #1, char 17:... (1 Reply)
Discussion started by: gammaman
1 Replies

2. Shell Programming and Scripting

Help for Sed Syntax problem

I have one File named "txt_file" # cat txt_file <DBType>RT</DBType> <AppType>RT</AppType> -------------------------------------------------- I want replace "<AppType>RT</AppType>" to <AppType>XY</AppType> in txt_file and output redirect to Newfile ... (2 Replies)
Discussion started by: SanjayLinux
2 Replies

3. Shell Programming and Scripting

Perl syntax for sed searches

I am aware that Perl has a lot of features that originally came from sed and awk. I have a pattern that I am using like this: sed -n '/|Y|/p' I want to do the same thing in Perl and be able to either save that value in some kind of variable or array or potentially write it out to a file. ... (11 Replies)
Discussion started by: masinick
11 Replies

4. Shell Programming and Scripting

Escape character - sed

Hi All, How do i write in sed for the 6th and 7th field of etc/passwd file as it involves "/" character? Does mine below is correct? It's incomplete script as i need help with syntax as i always getting may errors :( Example of etc/passwd file: blah:x:1055:600:blah... (6 Replies)
Discussion started by: c00kie88
6 Replies

5. Shell Programming and Scripting

SED: Replacing $1 with $2 escape problem

Hi all, I have a script which uses sed to replace one string with another. The problem is, the string to be matched, and its replacement are coming in as two command line arguments $1 and $2 $1 and $2 can be absolutely anything, but both should be treated purely as strings. My sed command... (7 Replies)
Discussion started by: mark007
7 Replies

6. Shell Programming and Scripting

perl how to escape (|) character

my @array; my $sepa = "|"; print $sepa; open FH, "<100_20091023_2.txt"; while(<FH>){ push @array, split(/\$sepa/, $_); print "@array\n\n"; } I am not able split the line which have | separated (1 Reply)
Discussion started by: pritish.sas
1 Replies

7. Shell Programming and Scripting

Problem with sed in perl!!

Hi, I am facing an issue with sed in perl. I have a file which has 2 header lines and one trailer line. I need to process the file without these headers and trailer. My file looks like : File.txt:- Header1 Header2 data1 data2 trailer For removing header and trailer from file I am using... (5 Replies)
Discussion started by: abhisharma23
5 Replies

8. Shell Programming and Scripting

Problem with using a sed to add escape character \ before $ and ' symbols

Hi all, I've got a problem with sed. Want to use it to add escape character \ before $ and ' symbols so condition='1'$some will become condition=\'1\'\$some echo "condition='1'$some" | sed 's/\($\)/\\\1/g' is not working properly. Can somebody help me with this please? Regards,... (7 Replies)
Discussion started by: johny_be_good
7 Replies

9. Shell Programming and Scripting

sed - with escape character

i have string as below str=".<date>" in which i need to replace < with /< , when i tried with sed , got the output. --> echo $str | sed 's/</\\</g' .\<date> when i tried to assign it to a variable , i am not getting the same --> a=`echo $str | sed 's/</\\</g'` ; echo $a... (4 Replies)
Discussion started by: expert
4 Replies

10. UNIX for Beginners Questions & Answers

How to escape % with sed?

Hello, I am running ubuntu 16.04 I searched "how to replace dot by % using sed" but no luck. file My.Name.Is.Earl Expected output My%Name%Is%Earl I tried: sed -i "s|.||g" file sed -i "s|.|{%}|g" file sed -i "s|.|\%|g" file I'd appreciate your help Thank you Boris (6 Replies)
Discussion started by: baris35
6 Replies
syntax(3)						User Contributed Perl Documentation						 syntax(3)

NAME
syntax - Activate syntax extensions VERSION
version 0.004 SYNOPSIS
# either use syntax 'foo'; # or use syntax foo => { ... }; # or use syntax qw( foo bar ), baz => { ... }; DESCRIPTION
This module activates community provided syntax extensions to Perl. You pass it a feature name, and optionally a scalar with arguments, and the dispatching system will load and install the extension in your package. The import arguments are parsed with Data::OptList. There are no standardised options. Please consult the documentation for the specific syntax feature to find out about possible configuration options. The passed in feature names are simply transformed: "function" becomes Syntax::Feature::Function and "foo_bar" would become "Syntax::Feature::FooBar". METHODS
import syntax->import( @spec ); This method will dispatch the syntax extension setup to the specified feature handlers for the calling package. import_into syntax->import_into( $into, @spec ); Same as "import", but performs the setup in $into instead of the calling package. unimport syntax->unimport( @features ); This method will trigger uninstallations of the @features from the calling package. unimport_from syntax->unimport_from( $from, @features ); Same as "unimport", but will uninstall the @features from $from. RECOMMENDED FEATURES
o Syntax::Feature::Function Activates functions with parameter signatures. SEE ALSO
Syntax::Feature::Function, Devel::Declare BUGS
Please report any bugs or feature requests to bug-syntax@rt.cpan.org or through the web interface at: http://rt.cpan.org/Public/Dist/Display.html?Name=syntax AUTHOR
Robert 'phaylon' Sedlacek <rs@474.at> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Robert 'phaylon' Sedlacek. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.18.2 2012-05-18 syntax(3)
All times are GMT -4. The time now is 07:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy