In sed you can replace the slash of the substitute command with almost any character .
Using | instead of / :
Another thing is that you may need extra backslashes within double quotes. So best to use single quotes..
Last edited by Scrutinizer; 11-24-2014 at 01:24 PM..
This User Gave Thanks to Scrutinizer For This Post:
Don't see LINUX or LVM in the output of fdisk -l. Maybe you are using other than GNU Linux?
What I see here...
In my case, $NewDisk appears to sed as a space separated list of commands, which are bogus...
The fix for me would be to make $NewDisk an array and access by [index]
In your case, making $NewDisk=csicc/c0d0p5 like you reported, still throws an error because sed sees the /slash in csicc/c0d0p5 as a delimiter...
So change the delimiter in sed from / to |...(ala Scrutinizer post #2)
Give it a go and lemme know if I need to make any edits here.
Hi All
I have one file with multiple lines in it, each line has static text and some variable enclosed in <<filename>> as well. e.g. as below
123, <<file1.txt>> this is my name, I stay at <<city.txt>> Thanks for visiting
348384y, this is my name <<fileabc.txt>>, I stay at near the mall of... (8 Replies)
Hi,
I have a ksh script where I am trying to mask the password in the log files.
$loc - is my directory
$PGUIDE_DB_USER_PSW - is a variable that holds the password I am looking for
find $loc/logs -type f -exec sed -i "s/$PGUIDE_DB_USER_PSW/*****/"g {} \;
I get an error:
... (2 Replies)
Hi,
I am trying to replace the value of a variable in a file through another script.
Example:
Filename : abc.txt contents:
a=10
b=20
c=30
Need to change the value of, say, b - Tried using the following:
sed "s/${b}/15/g" abc.txt
Have tried various forms of sed (with single quotes,... (4 Replies)
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)
Hi guys,
Hi have this input (Menu.xml)<?xml version="1.0" encoding="ISO-8859-1"?>
<breakfast_menu>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
... (6 Replies)
Hello,
I have this command and it works fine.
My question is that how can we replace the N by a variable, to print for instance a big number of lines. It means if I want 100 lines after an expression, to not put "N" 100 times in the sed.
Code:
$ sed -n '/aaa/{n;N;N;s///g;s/;/; /g;p;}'... (2 Replies)
Ok, so, let's say I have the variable $GMAILID....How can I use it with sed command so to replace a string in a file? e.g.:
sed -i 's/$GMAILID/test@gmail.com/' /home/$USER/Desktop/sendmail (4 Replies)
I'm trying to replace text in a file with text from a variable
I have the following in my script, but its not working:
#!/bin/ksh
echo "Enter the path to load scripts"
read x
echo "updating the templates"
sed "s/CHANGE_ME_TO_LOAD_PATH/"$x"/g" LoadFiles.sh > LoadFiles2.sh
I thought... (1 Reply)
Hello everyone,
I need to replace a pattern with "value of a variable" using sed but no luck.
i tried the below
ABC=STR2
sed 's/STR1/$ABC/g' <file>
(also tried \ , $ and " in combination but failed)
Appreciate any help.
Thanks
Prvn (2 Replies)