[SOLVED]assigning "special" shell [variable] to awk, got problem
$ VAR='AB' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [1]
Z
$ VAR='[AB]' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [2]
[ZZ]
$ VAR='[AB' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [3]
awk: (FILENAME=- FNR=1) fatal: Unmatched [ or [^: /[AB/
$ VAR='AB]' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}' # [4]
Z
Just read about this:
Regular Expression Operators @ The GAWK Manual wrote:
This is called a character set. It matches any one of the characters that are enclosed in the square brackets. For example:
[MVX]
matches any of the characters `M', `V', or `X' in a string.
And I tried,
$ echo "[AB]" | awk '{gsub(/\[AB\]/,"Z");print}' #[5]
Z
$ echo "[AB]" | awk '{gsub(/[AB]/,"Z");print}' #[6]
[ZZ]
[2] is behaving like [6] when I actually want it to be acting like [5].
What syntax should I use?
Last edited by lolilolicon (2009-08-16 10:58:28)
fumbles, I'm sorry I didn't explain myself clearly.
$ VAR='[AB]' ; echo "$VAR" | awk -v foo="$VAR" '{gsub(foo,"Z");print}'
outputs:
[ZZ] --> awk replaces each of A and B with Z, and left '[]' intact.
What I want is:
Z --> awk treats '[AB]' as a whole normal input, just like 'ABCD' or whatever...
Just like what I said, "[2] is behaving like [6] when I actually want it to be acting like [5]."
I need to do this because I'm writing a script where shell variable is assigned to awk variable, which contains '[]'. Like you said, awk is treating it as part of a regular expression...
EDIT:
Ok, an ugly solution::
$ VAR='[AB]'
$ VAR=$(echo "$VAR" | sed 's/\[/\\\\\[/;s/\]/\\\\\]/') #now VAR='\\[AB\\]'
$ echo "[AB]" | awk -v foo="$VAR" '{gsub(foo,"Z");print}'
Z
This almost sovles the problem I encountered in the script.
But there should be a better answer!
Say, is there a way to turn off awk's regular expression? --> Just found out grep's -F option. How about awk??
Last edited by lolilolicon (2009-08-16 08:42:36)
Similar Messages
-
Hi, i want to use tr command in awk. Please guide me. Also, how to use shell variables in awk?
please help
-
i've just tryed to write unsigned in32, but it does not understand 'unsogned'... But i need variable to be unsigned, because the max value = 4000000000... So, how can i solve this probleme???
Hi,
I don't see exactly what you're trying to do here.
Where do you want to assign the variable 4000000000 to? If you want it as an
input, just use a dbl, with only zeros behind the coma.
Note that an integer is a number without any decimals. An integer in LabVIEW
is this, but with an extra limitation that it can only be 32 bits... So a
dbl can be an integer.
If the input dbl is not an integer, use round, round to -inf or round to
+inf to make it one. This can also be done if the output needs to be an
integer.Inside the formula node floor(x), int(x), intrz(x) or ceil(x) can be
used to make integers.
I hope this is what you mean... I can't see any problems doing this.
Regards,
Wiebe.
"DrON" wrote in message
news:506500000008000000E
[email protected]..
> I need in Formula Node to assign to the variable value 4000000000!!!
> What kind of variable it should be???
>
> i've just tryed to write unsigned in32, but it does not understand
> 'unsogned'... But i need variable to be unsigned, because the max
> value = 4000000000... So, how can i solve this probleme??? -
Export shell variables into SPS variables
I am looking for a way to assign shell variables which are defined in the "exec native" step, as a N1 variable.
I will use this variable to generate a more userfriendly output in the "raise message"
Has anyone an idea??
ThanxDo you mean that you want to assign a value from within a shell variable to an N1 variable? If so, then you can use the <assignOutput> element in execNative. Here's an example:
<varList>
<var name="var1" default="not assigned"/>
</varList>
<simpleSteps>
<execNative>
<assignOutput varName="var1"/>
<exec cmd="echo">
<arg value="${my_shell_var}"/>
</exec>
</execNative>
<raise message=":[var1]"/>
</simpleSteps>
... -
How To Assign Special sms Tone For Special Contact
Hi
i have nokia N70 , is there any way to assign special sms tone for special contact ?
Solved!
Go to Solution.Unfortunately not.
-
How can i assign a Javascript variable to JSP variable
Hi guys
how i can assign a javascript variable to jsp expression.,
e.g.,
<input type = "button" value = "Add more" onclick = "return submitform1('<%=s%>')">
function submitform1(String s)
var s1 = s
document.form1.action = "../intimation.do"; /* Here i want to pass the value s1 to jsp or servlets without using hidden fields and Query string*/
document.form1.submit();
return false;
/* i want to pass the values thru session whether it is possible */
pls give sample code
Reply
MarimuthuYou don't have the session.
All you have is HTTP.
The only way to communicate from the client to the server is via an HTTP request. The only way to send a value like that is with a parameter.
Using a form with method="submit" as mentioned will pass the parameters without displaying them in the url bar (is that what you wanted?) -
Get value from PL/SQL procedure to shell variable
Hello,
I have one little problem. I want to run plsql procedure from shell program and then I want to fill a shell variable with return value of plsql procedure or function. But I don't want to pass this value to some file and then read it.
Thank'suser9357436 wrote:
Hello,
I have one little problem. I want to run plsql procedure from shell program and then I want to fill a shell variable with return value of plsql procedure or function. But I don't want to pass this value to some file and then read it.
Thank'sLike below?
bcm@bcm-laptop:~$ cat day.sh
set X
var1=$1
SQLPLUS="sqlplus -s"
LOGON="user1/user1 "
day=`$SQLPLUS $LOGON <<EOF
set heading off
set feedback off
set verify off
select 'Have a nice day!' from dual where dummy ='$var1';
exit;
EOF`
echo $day
bcm@bcm-laptop:~$ ./day.sh
Have a nice day!
bcm@bcm-laptop:~$ -
Assign a Javascript variable value to a ABAP variable
Hi,
I wish to assign a javascript variable value to a ABAP variable. Any ideas how to do that?
Many thanks.
Rgds,
BerniceHere's another suggestion for you.
BSP Application: SBSPEXT_HTMLB
Check out the radionbuttongroup.bsp
So then instead of using a standard HTML radio buttons you can use the HTMLB element with the parameter for onClick set then in your DO_HANDLE_EVENT you can read the value.
VIEW
<htmlb:radioButtonGroup id="radio">
<htmlb:radioButton id="id_link"
text="Link"
onClick="myClickHandler"/>
<htmlb:radioButton id="id_unlink"
text="Unlink"
onClick="myClickHandler"/>
</htmlb:radioButtonGroup>
DO_HANDLE_EVENT
DATA: lt_event TYPE REF TO if_htmlb_data.
lt_event = cl_htmlb_manager=>get_event_ex( request ).
if lt_event IS NOT INITIAL.
if lt_event->event_name = htmlb_events=>radiobutton.
case lt_event->event_id.
when 'control_id_link'.
schalter = ' '..
when 'control_id_unlink'.
schalter = '1'.
endcase.
endif.
endif.
There is an example of how to use it and read it in the DO_HANDLE_EVENT you then just have to pass the variable around (in this example the variable name is schalter and is defined as char1 in the class) -
Assigning Value to Variable in Sapscript
Hi,
To initialized value of the variable when I tried to assign 0 to variable (like in the following statement) it comes up with error 'Command Expected'.
&RF140-ZALBT&= '0'.
Please let me know where and what I am doing wrong in assigning value to a variable?
Regards,
ShabbarHi,
Still its not working. The statement I am writing is
/: &NET& = &RF140-WRSHB& - &RF140-MSATZ&
but the system gives error on that.
NET is the local variable declared with Define statement and both the others are defined in print program.
Even I tried
/: &RF140-ZALBT& = &RF140-WRSHB& - &RF140-MSATZ&
but still the same error.
Any comments?
Regards,
Shabbar -
How to assign a JSP variabl's value to a JavaScript variable?
Hello,
I want to assign a JSP variable's value to JAVASCRIPT variable.
or how to assign JavaScript variable's value to JSP varialbe
HOw do i do it ?
can anyone please help?
Regards and thanks for your time.
AshviniI want to assign a JSP variable's value to
JAVASCRIPT variable.
var jsVariable = <%=someVariable%>;
or how to assign JavaScript variable's value to JSP
varialbeYou can't. JSP is server-side and JavaScript is client-side. The JSP variables are never available on the client side for any sort of assignment. -
How to pass a shell variable to rman scripts
I want to backup datafile to different directory
depending on the current time,and I can do this to
pass a shell variable to rman scripts,and this
variable will used as part of format ,like this:
backup incremental level=0
tag rman_inc0_bck
filesperset 5
format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
(database include current controlfile)
and $(DIR) is shell variable ,but rman will not
recognize this ,how to achieve this?You could send your script to rman thru a pipe | or <<
echo "backup incremental level=0
tag rman_inc0_bck
filesperset 5
format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
(database include current controlfile);" | rman target /You could also create a "temp script" and then use it from rman with cmdfile
sed "s,XXXDIR,$(DIR)," yourtemplate > /tmp/rmanscript.$$
rman target / cmdfile /tmp/rmanscript.$$
rm /tmp/rmanscript.$$ -
How to store multiline string literal in to java bean shell variable
Hello Experts
How to store multiline string literals in java bean shell like we use triple quote for jython variable
Using Jython
str=""" helllo
welcome to my world"""
above syntax is working but not for java bean shell like below
String str=""" hello
welcome to my world""";
So how to do this in java bean shell. I came to this scenario while storing logs to a variable. I believe there is no solution for storing multiline strings to java bean shell variable.
<@
String str="<%=odiRef.getPrevStepLog("MESSAGE")%>";
@>
Any suggestion will be highly appreciated.
Thank You.maddythehunk wrote:
Im trying this but its not working...
while(billingQueryParamsItr.hasNext()) {
billingQueryParam = (BillingQueryParam) billingQueryParamsItr.next();
System.out.println("****** Param Name-->"+billingQueryParam.getParamName());
String[0] name = billingQueryParam.getParamName(); // giving error ; expected
//billingItemActionForm.setParamName(billingQueryParam.getParamName());
Declare the array outside of the loop. Fill the array as you iterate. And stop putting your error messages inside of comments in the code. -
How to assign a Substitution variable dynamically?
Hi All,
I was trying to assign a substitution variable which should get data from the time period and should directly load into the substitution variable automatically.
The process should be automated. so as to refrsh the substitution variable daily.
Any comments are highly appreciated
With Regrads
PradsSorry for the double-post, I didn't quite get that you wanted to read the Time Period dimension.
Is that what you are trying to do? Get a list of the periods (usually these are pretty well known) and then find the latest one for a given member combination that has data and then set a substitution variable off of that?
You can run reports (or DATAEXPORT calc command) to get data from MaxL.
Or are you trying to do something else?
Regards,
Cameron Lackpour -
How to use an UNIX shell variable in sql where clause
Hi ,
In my shell script first I get the Date and time from the system into the shell variable.At the end of the shell script I need to run a sql script in which I want to use the variable value in the where clause . Is there any way we can use a shell variable value in SQl script ?. Any help is greatly appriciated .
Thanks in advance,
SampathTry the following
In Unix
SQLPLUS <username>/<password> @MyScript.sql <UNIX_Variable>
In SQL*Plus
Reference the variable as &1
select *
from MyTable
where MyDate = to_date('&1','<date_format>'); -
How could I get unix shell variable value?
I want to get a unix shell variable value because I will use it in my java program. For example $HOME, I have wrote like below,
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("echo $HOME");
But I could not get $HOME value, just get "$HOME" as result.
Why could not I get the value?Other than passing them as params to your program, the only way to read them runtime is either pipe them thru a stream or use JNI.
Maybe you are looking for
-
REPORT_DESNAME with a space!
I have a requirement to send a report to an email gateway in a specific format. This REQUIRES that the desname parameter contains a space. I am running into errors. Is it possible for this parameter to contain a space? I am on 10g.
-
It is an oldish computer running windows XP, moving to firefox since I used it on my laptop and wanted to put it on this computer. I ran the setup and it says it is not a valid win32 application and closes, well i say close, it barey opens. i also tr
-
Mega drop down SharePoint 2013 - Any more third party tool
Im looking for a mega dropdown menu to use in a sharepoint 2013 project. I'm happy to use a third party one like this one archetonomy But i need some other similar ones to compare too but can't find any. I would appreciate if can find more of this. T
-
I dont know where is problem but my iBook G4 cannot boot. If I use verbose mode it says "Still waiting for boot device.." So i boot from cd and check disk with disk utitility (verified and repair)both this procedure fails with "The underlying task re
-
Customize item under the Tools menu removed from Designer 9.0
Hello all, I have a client who used the Customize functionality under the Tools menu in Designer 8.2. After they upgraded to LC ES2 and Designer 9.0, they discovered this functionality is now missing, despite the fact that it is still referenced in