Sponsored Content
Top Forums Shell Programming and Scripting Perl/sed Escape Syntax Problem . . . Post 302923756 by bartus11 on Tuesday 4th of November 2014 11:13:56 AM
Old 11-04-2014
You can also do something like this:
Code:
#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

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

No more double backslash, but you have to change the quote character in the sed command.
This User Gave Thanks to bartus11 For This Post:
 

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
PERLUTS(1)						 Perl Programmers Reference Guide						PERLUTS(1)

NAME
perluts - Perl under UTS SYNOPSIS
This document can be read as is: as README.uts, or you can read it after you build your package using "man perluts". The purpose is to help you build Perl for UTS, which, if you follow these instructions, should be easy, and result in a solidly working installation. DESCRIPTION
Perl 5.7.2 (Developmental) or Perl 5.8.x (forthcoming) for UTS BUILDING PERL ON UTS
NOTE: Some sites have redefined the way uname works, and if yours does this, special steps must be taken so that Configure can recognize your system as a UTS system. To see if you are in this category, issue the command "uname -a". It should look something like: uts juno 4 4.4 9672 370 At any rate, the first field should be "uts". If this is not the case; supposing it is, say telcoUTS, create a script, uts/uname (i.e. uname, in the subdirectory "uts" of the main Perl source dir): # uname /usr/bin/uname "$@" | sed -e 's/^telcoUTS/uts/' and when you execute Configure, do it as below, except for adding PATH=uts:$PATH as a prefix. I.e. do: PATH=uts:$PATH ./Configure ... There is no need to do an interactive configure, just type ./Configure -de [-Dusedevel] [-Doptimize=-g ] 2>&1 | tee Conf.out "-Dusedevel" may be required to configure Perl 5.7.2 non-interactively. Use -Doptimize=-g if you want to run Perl under sdb or gdb, OR if you want to be able to use the -D command line flags to perl, which are occasionally useful in debugging perl scripts. In this and the following steps, the "2>&1 | tee XXX.out" records all output from the process, which will be useful if anything unexpected goes wrong. Then do the compilation with make 2>&1 | tee make.out Finally, test using make test 2>&1 | tee make-test.out In the output, the only failures you should see should look like: lib/Math/BigInt/t/bigfltpm.........Use of uninitialized value ... FAILED at test 57 lib/Math/BigInt/t/bigintc..........ok lib/Math/BigInt/t/bigintpm.........FAILED at test 204 lib/Math/BigInt/t/mbimbf...........Use of uninitialized value ... Illegal division by zero at ../lib/Math/BigInt/Calc.pm line 314. FAILED at test 71 lib/Math/Complex...................exp: OVERFLOW FAILED at test 250 lib/Math/Trig......................exp: OVERFLOW ok lib/Memoize/t/array................ok ... lib/Net/protoent...................ok lib/Net/servent....................FAILED at test 0 This means that everything passes except for some problems in the packages "Math::BigInt", "Math::Complex", and "Math::Trig". The lib/Net/servent failure seems to be a bug in the test program. To confirm this, from the main Perl source dir, do: LD_LIBRARY_PATH=`pwd` ./perl -Ilib lib/Net/servent.t and it should output 1..3 ok 1 ok 2 ok 3 Installing the built perl on UTS Run the command "make install" AUTHOR
Hal Morris UTS Global LLC email: hom00@utsglobal.com perl v5.8.0 2003-02-18 PERLUTS(1)
All times are GMT -4. The time now is 01:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy