Expand an environment variable in sed, when the variable contains a slash
I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash".
This gives me the following error:
Obviously this is because of the slashes in the HOME variable. How do I get around this problem?
$ . oraenv (when i type this at the prompt)
ORACLE_SID = ? ( I get this)
I understand that . oraenv is a startup script and it has the ENV variable ORACLE_SID.
But pls let me know what more it explains and also how to change the env variable here. (2 Replies)
Can I sed on an environment variable, even if I don't need to actually change said (hah, hah) variable? Something like:
sed s/xyz/abc/g $myvar
Then if I did need to change $myvar I could maybe do:
$myvar=`sed s/xyz/abc/g $myvar` (3 Replies)
Hi,
Can you tell me how to escape a variable number of slash characters in sed "/" ?
In the script the code looks like this:
cat $file_to_update | sed s/^$param/$param=$tab2*\#\*/1
And the $tab2 value is a path so it will have a number of "/" charracters.
# cat db.cfg | sed... (4 Replies)
Hello,
i have another sed question.. I'm trying to do variable substition with sed and i'm running into a problem.
my var1 is a string constructed like this:
filename1 filerev1 filepath1
my var2 is another string constructed like this:
filename2 filerev2 filepath2
when i do... (2 Replies)
I want to instert Category:XXXXX into the 2. line
something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong:
sed "2i\\${n}Category:$cat\n"
Sample:
Titel Blahh Blahh abllk sdhsd sjdhf
Blahh Blah Blahh
Blahh
Should look like... (2 Replies)
Hi all,
I need to know way of inserting backward slash before forward slash. My problem is that i need to supply directory path as an argument while invoking cshell script. This argument is further used in script (i.e. sed is used to insert this path in some file). So i need to place \ in front... (2 Replies)
Hi!
Ok, so I'm no programmer and I have basically no experience in these stuff. However I need to work on a thing (I think you call it Framework) called Root. It's a tool used by physicists. In the manual they keep talking about Environment variable. Even thou I searched for what it is on the... (5 Replies)
Hi All,
I am new to SUN Solaris.I have some questions regarding environment variable.:confused:
Q1. Where the environment variables available in Solaris.
Q2. What command used here.
Q3. Can a user change this .Suppose i want to change the bash to ksh can it be possible here. Or i need to... (2 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)
Dear Forum members,
I am having trouble getting the complete filename (and directory path) in a variable.
Output directory mentioned in the code have three files:
DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_london.out
DISPLAY_CITY_DETAILS_15-05-2019-08-29-26_MIGRATE_paris.out... (4 Replies)
Discussion started by: chetanojha
4 Replies
LEARN ABOUT MOJAVE
tcl_substobj
Tcl_SubstObj(3) Tcl Library Procedures Tcl_SubstObj(3)__________________________________________________________________________________________________________________________________________________NAME
Tcl_SubstObj - perform substitutions on Tcl objects
SYNOPSIS
#include <tcl.h>
Tcl_Obj *
Tcl_SubstObj(interp, objPtr, flags)
ARGUMENTS
Tcl_Interp *interp (in) Interpreter in which to execute Tcl scripts and lookup variables. If an error occurs, the interpreter's
result is modified to hold an error message.
Tcl_Obj *objPtr (in) A Tcl object containing the string to perform substitutions on.
int flags (in) ORed combination of flag bits that specify which substitutions to perform. The flags TCL_SUBST_COM-
MANDS, TCL_SUBST_VARIABLES and TCL_SUBST_BACKSLASHES are currently supported, and TCL_SUBST_ALL is pro-
vided as a convenience for the common case where all substitutions are desired.
_________________________________________________________________DESCRIPTION
The Tcl_SubstObj function is used to perform substitutions on strings in the fashion of the subst command. It gets the value of the string
contained in objPtr and scans it, copying characters and performing the chosen substitutions as it goes to an output object which is
returned as the result of the function. In the event of an error occurring during the execution of a command or variable substitution, the
function returns NULL and an error message is left in interp's result.
Three kinds of substitutions are supported. When the TCL_SUBST_BACKSLASHES bit is set in flags, sequences that look like backslash substi-
tutions for Tcl commands are replaced by their corresponding character.
When the TCL_SUBST_VARIABLES bit is set in flags, sequences that look like variable substitutions for Tcl commands are replaced by the con-
tents of the named variable.
When the TCL_SUBST_COMMANDS bit is set in flags, sequences that look like command substitutions for Tcl commands are replaced by the result
of evaluating that script. Where an uncaught "continue exception" occurs during the evaluation of a command substitution, an empty string
is substituted for the command. Where an uncaught "break exception" occurs during the evaluation of a command substitution, the result of
the whole substitution on objPtr will be truncated at the point immediately before the start of the command substitution, and no characters
will be added to the result or substitutions performed after that point.
SEE ALSO
subst(n)
KEYWORDS
backslash substitution, command substitution, variable substitution
Tcl 8.4 Tcl_SubstObj(3)