1. The problem statement, all variables and given/known data:
Hi,
I am trying to substitute an attributes value using sed command but it is only possible to substitute the value without space.
2. Relevant commands, code, scripts, algorithms:
input xml
it will read the attribute and value will store it in variable
required output
3. The attempts at a solution (include all code and scripts):
I used the following script
It is possible to substitute the attribute's value with this code with no space but it is not possible the f value substitution (The one with the space) with this script
How to implement this scenario?
#
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course)
School Name:Jalpaiguri Govt Engg College
Professor:Swapan kr Sengupta
Course Number:CSE502
Last edited by Don Cragun; 08-12-2015 at 11:51 AM..
Reason: Change ICODE tags to CODE tags.
I know we can substitute a string using sed but how?
For example: sed 's/(old variable)/(new variable)/ details.dat
Am I suppose to put $old variable or whatever? Because I tried many times, it didnt work by putting $old variable. Am I suppose to enclose it with "" or ''?
Please help (3 Replies)
Hi,
I have a set of files containing strings like I.TEST1_TEST2 or B.ESSA_ESSB for example.
Does somebody know how to substitute these strings whith the same name and an extension "_V1" (ie. I.TEST1_TEST2_V1) using sed command or else ? (3 Replies)
Hi ,
I am stuck up in the below scenario:-
I need to read a file name (eg A.txt) name frm another file (eg B.txt) and then I need to search for a particular expression in A.txt and substitute it with another expression.
How can I use SED inside SHELL Scripting and command prompt as... (2 Replies)
Hi ,
I am stuck up in the below scenario:-
I need to read a file name (eg A.txt) name frm another file (eg B.txt) and then I need to search for a particular expression in A.txt and substitute it with another expression.
How can I use SED inside SHELL Scripting and command prompt as well to... (1 Reply)
I have file.txt
1 4 7 9 3
I want to replace the tabs with a space, but my code doesn't work.
cat file.txt | sed 's/"\t"/ /g' > t.txt
But file is still the same. Numbers seperated by tabs instead of spaces.
Help? (2 Replies)
Hi I am trying to do a text insertion in a text file at a particular line number in a shell script. However its not working.
sed '122i\
> for j in \`echo $MyList\` ; do perl -pi -e\'s#01\/01\/2009#01\/01\/2011#\' $j ; done' $HOME/MyScript.ksh
The Actual line to be inserted at line 122... (5 Replies)
Hi,
I would like to know if there is a command similar to scsimgr in HP-UX that
can help me change the algorithm and reserve_policy attributes of all luns presented to an AIX host.
Otherwise I would have to use,
chdev -l hdiskX -a algorithm=round_robin reserve_policy=no_reserve
in a... (1 Reply)
I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename?
#!/bin/bash
filename=`echo $0`
/usr/bin/sed '/#include/ {
i\
the filename is `$filename`
}' $1
exit 0 (8 Replies)
Hi everyone,
I need very simple sed command to change a parameter in a text file.
I have a line in this text which is like
set xx 0.5
A program reads this file and does some algebraic calculations. So to make a parameter scan I need to change the value of xx. I thought I can do... (7 Replies)
Hi,
I am trying to substitute an attributes value using sed command but it is only possible to substitute the value without space.
input xml
<BillingAddress11300000 Tag="11300000" SectionID="BLA" CustAddrName="CLAUDIA LUCIA DE ALMEIDA" CustAddrStreet="AV ENGENHEIRO RICHARD" CustAddrState="RJ"... (3 Replies)
Discussion started by: Bijayan Sarkar
3 Replies
LEARN ABOUT SUSE
catch
catch(n) Tcl Built-In Commands catch(n)
__________________________________________________________________________________________________________________________________________________NAME
catch - Evaluate script and trap exceptional returns
SYNOPSIS
catch script ?resultVarName? ?optionsVarName?
_________________________________________________________________DESCRIPTION
The catch command may be used to prevent errors from aborting command interpretation. The catch command calls the Tcl interpreter recur-
sively to execute script, and always returns without raising an error, regardless of any errors that might occur while executing script.
If script raises an error, catch will return a non-zero integer value corresponding to the exceptional return code returned by evaluation
of script. Tcl defines the normal return code from script evaluation to be zero (0), or TCL_OK. Tcl also defines four exceptional return
codes: 1 (TCL_ERROR), 2 (TCL_RETURN), 3 (TCL_BREAK), and 4 (TCL_CONTINUE). Errors during evaluation of a script are indicated by a return
code of TCL_ERROR. The other exceptional return codes are returned by the return, break, and continue commands and in other special situa-
tions as documented. Tcl packages can define new commands that return other integer values as return codes as well, and scripts that make
use of the return -code command can also have return codes other than the five defined by Tcl.
If the resultVarName argument is given, then the variable it names is set to the result of the script evaluation. When the return code
from the script is 1 (TCL_ERROR), the value stored in resultVarName is an error message. When the return code from the script is 0
(TCL_OK), the value stored in resultVarName is the value returned from script.
If the optionsVarName argument is given, then the variable it names is set to a dictionary of return options returned by evaluation of |
script. Tcl specifies two entries that are always defined in the dictionary: -code and -level. When the return code from evaluation of |
script is not TCL_RETURN, the value of the -level entry will be 0, and the value of the -code entry will be the same as the return code. |
Only when the return code is TCL_RETURN will the values of the -level and -code entries be something else, as further described in the doc- |
umentation for the return command. |
When the return code from evaluation of script is TCL_ERROR, three additional entries are defined in the dictionary of return options |
stored in optionsVarName: -errorinfo, -errorcode, and -errorline. The value of the -errorinfo entry is a formatted stack trace containing |
more information about the context in which the error happened. The formatted stack trace is meant to be read by a person. The value of |
the -errorcode entry is additional information about the error stored as a list. The -errorcode value is meant to be further processed by |
programs, and may not be particularly readable by people. The value of the -errorline entry is an integer indicating which line of script |
was being evaluated when the error occurred. The values of the -errorinfo and -errorcode entries of the most recent error are also avail- |
able as values of the global variables ::errorInfo and ::errorCode respectively. |
Tcl packages may provide commands that set other entries in the dictionary of return options, and the return command may be used by scripts |
to set return options in addition to those defined above.
EXAMPLES
The catch command may be used in an if to branch based on the success of a script.
if { [catch {open $someFile w} fid] } {
puts stderr "Could not open $someFile for writing
$fid"
exit 1
}
There are more complex examples of catch usage in the documentation for the return command.
SEE ALSO
break(n), continue(n), dict(n), error(n), return(n), tclvars(n)
KEYWORDS
catch, error
Tcl 8.5 catch(n)