10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
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
2. Shell Programming and Scripting
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
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
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
10. UNIX for Dummies Questions & Answers
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