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)
I want to replace a string which contains "/" in vi but what is the escape character for forward slash?
e.g. I have a text file with the contents below and I want to replace "/Top/Sub/Sub1" with "ABC".
/Top/Sub/Sub1
The replace command I am using is ... (4 Replies)
Hi ,
I want to change space to ' in my script.
I tried doing this,
sed 's/ /\'/g' filename
but i could not get it.
can some one help me please.
Thanks,
Deepak (4 Replies)
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)
All ,
i have input line as below .
abc\ , ewioweioi \,
and want the output as below removing the "\"
abc , ewioweioi ,
could anyone help me out (2 Replies)
I need to change a pattern with single quotes
# echo "serversignature: 'On'"
serversignature: 'On'
I did
# echo "serversignature: 'On'" | sed 's/.*serversignature.*/serversignature: 'Off'/'
serversignature: Off
The output I need is with single quotes. But its swallowing it.
... (2 Replies)
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)
Hi,
How to use * in call to pl/sql block from shell script?
The line "select * from" is causing all files and directiores to show up in email notification but if I give all column names then it works,
Please let me know how to use '*' instead of giving all column names, in other wirds how to... (2 Replies)
Hi ,
I am looking for a function which will do the following.
1. I have a variable which will hold few special chracter like
SPECIAL_CHARS="& ;"2. I have an escape character.
ESCAPE_CHAR="\"3. Now when I passed some string in the function it will return the same string but now it will... (8 Replies)
Hi,
I want to store ^M character in a variable to be later written to a file. Can you please help.
TempOut="$_var1 `print '\x0D'` $_var1"
.....
....
echo $TempOut >> logfile
TempOut="$_var1 `echo -e '\x0D'` $_var1"
.....
....
echo $TempOut >> logfile
But both ways I am... (2 Replies)
Discussion started by: tostay2003
2 Replies
LEARN ABOUT SUSE
pdl::char
Char(3) User Contributed Perl Documentation Char(3)NAME
PDL::Char -- PDL subclass which allows reading and writing of fixed-length character strings as byte PDLs
SYNOPSIS
use PDL;
use PDL::Char;
my $pchar = PDL::Char->new( [['abc', 'def', 'ghi'],['jkl', 'mno', 'pqr']] );
$pchar->setstr(1,0,'foo');
print $pchar; # 'string' bound to "", perl stringify function
# Prints:
# [
# ['abc' 'foo' 'ghi']
# ['jkl' 'mno' 'pqr']
# ]
print $pchar->atstr(2,0);
# Prints:
# ghi
DESCRIPTION
This subclass of PDL allows one to manipulate PDLs of 'byte' type as if they were made of fixed length strings, not just numbers.
This type of behavior is useful when you want to work with charactar grids. The indexing is done on a string level and not a character
level for the 'setstr' and 'atstr' commands.
This module is in particular useful for writing NetCDF files that include character data using the PDL::NetCDF module.
FUNCTIONS
new
Function to create a byte PDL from a string, list of strings, list of list of strings, etc.
# create a new PDL::Char from a perl array of strings
$strpdl = PDL::Char->new( ['abc', 'def', 'ghij'] );
# Convert a PDL of type 'byte' to a PDL::Char
$strpdl1 = PDL::Char->new (sequence (byte, 4, 5)+99);
$pdlchar3d = PDL::Char->new([['abc','def','ghi'],['jkl', 'mno', 'pqr']]);
string
Function to print a character PDL (created by 'char') in a pretty format.
$char = PDL::Char->new( [['abc', 'def', 'ghi'], ['jkl', 'mno', 'pqr']] );
print $char; # 'string' bound to "", perl stringify function
# Prints:
# [
# ['abc' 'def' 'ghi']
# ['jkl' 'mno' 'pqr']
# ]
# 'string' is overloaded to the "" operator, so:
# print $char;
# should have the same effect.
setstr
Function to set one string value in a character PDL. The input position is the position of the string, not a character in the string. The
first dimension is assumed to be the length of the string.
The input string will be null-padded if the string is shorter than the first dimension of the PDL. It will be truncated if it is longer.
$char = PDL::Char->new( [['abc', 'def', 'ghi'], ['jkl', 'mno', 'pqr']] );
$char->setstr(0,1, 'foobar');
print $char; # 'string' bound to "", perl stringify function
# Prints:
# [
# ['abc' 'def' 'ghi']
# ['foo' 'mno' 'pqr']
# ]
$char->setstr(2,1, 'f');
print $char; # 'string' bound to "", perl stringify function
# Prints:
# [
# ['abc' 'def' 'ghi']
# ['foo' 'mno' 'f'] -> note that this 'f' is stored "f "
# ]
atstr
Function to fetch one string value from a PDL::Char type PDL, given a position within the PDL. The input position of the string, not a
character in the string. The length of the input string is the implied first dimension.
$char = PDL::Char->new( [['abc', 'def', 'ghi'], ['jkl', 'mno', 'pqr']] );
print $char->atstr(0,1);
# Prints:
# jkl
perl v5.12.1 2009-10-17 Char(3)