ersatz
asked on
substr-awk problem
Hi,
I am not a unix specialist but I need a script to resolve my problem. I know the algorithm but I don’t know to write this using awk in my script.
I want to have something like this:
If substr($6, length($6-1) =”_” then
TBL=$6$REG_TBL
Else
TBL=substr($6,1,18)$REG_TB L”_DM”
endif
Can somebody help my, please?
Thanks in advance
P.S. I take $6 from rfsh.env file
I am not a unix specialist but I need a script to resolve my problem. I know the algorithm but I don’t know to write this using awk in my script.
I want to have something like this:
If substr($6, length($6-1) =”_” then
TBL=$6$REG_TBL
Else
TBL=substr($6,1,18)$REG_TB
endif
Can somebody help my, please?
Thanks in advance
P.S. I take $6 from rfsh.env file
> substr($6, length($6-1)
returns a string >= 0 characters
did you probably mean
substr($6,length($6))
Then it's something like this:
{ REG_TBL_DM='irgendein ersatz'; REG_TBL='ersetzen';
if (substr($6,length($6)) == "_"){
TBL=$6REG_TBL
} else {
TBL=substr($6,1,18)$REG_TB L_DM
}
returns a string >= 0 characters
did you probably mean
substr($6,length($6))
Then it's something like this:
{ REG_TBL_DM='irgendein ersatz'; REG_TBL='ersetzen';
if (substr($6,length($6)) == "_"){
TBL=$6REG_TBL
} else {
TBL=substr($6,1,18)$REG_TB
}
I think he means ..................
if last char of $6 is "_" then table name will be $6$REG_TBL
otherwise It will be "first 18 char of $6" + $REG_TBL + "_DM"
ASKER
Hi,
You have right,I made a mistake.
My 6th column contains a variable string.
Example of this field value: F4REP_ACCOUNT_OUT_
or F4REP_ACCOUNT_OUT_ _DM.
REG_TBL=MMFSA
If substr($6, length($6-1), 1) =”_” then
TBL=$6$REG_TBL ($6 concatenate with $REG_TBL)
Else
TBL=substr($6,1,18)$REG_TB L”_DM” (substr($6,1,18) concatenate with $REG_TBL concatenate with "_DM"
endif
I am waiting for your answer.
Thanks again
You have right,I made a mistake.
My 6th column contains a variable string.
Example of this field value: F4REP_ACCOUNT_OUT_
or F4REP_ACCOUNT_OUT_ _DM.
REG_TBL=MMFSA
If substr($6, length($6-1), 1) =”_” then
TBL=$6$REG_TBL ($6 concatenate with $REG_TBL)
Else
TBL=substr($6,1,18)$REG_TB
endif
I am waiting for your answer.
Thanks again
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if the answer was just worth a B grading, what is more worth than mine?
ii can not understand the question.