0
I've tried Googling this and tested every permutation I could come up with, but I'm just not getting it. :(
I have a function which accepts an identified input string:
[user@Dreadnaught /]$ myfunction -w InputString
The function has several input options, so I need to identify that I'm passing my string to the -w option. The string I'm getting from another program has dashes in it:
In-put-St-ring
I can remove those dashes when testing an echo:
[user@Dreadnaught /]$ echo "In-put-St-ring" |tr -d -
InputString
But I can't figure out how to strip the dashes when passing to the function. I've tried (unsuccessfully):
[user@Dreadnaught /]$ OldString="In-put-St-ring"
[user@Dreadnaught /]$ echo $OldString
In-put-St-ring
[user@Dreadnaught /]$ NewString=$OldString|tr -d -
[user@Dreadnaught /]$ echo $NewString
[user@Dreadnaught /]$ NewString=$($OldString|tr -d -)
-ash: In-put-St-ring: not found
[user@Dreadnaught /]$ NewString=$("$OldString"|tr -d -)
-ash: In-put-St-ring: not found
[user@Dreadnaught /]$ NewString=$(""$OldString"|tr -d -")
-ash: In-put-St-ring|tr -d -: not found
and...
[user@Dreadnaught /]$ myfunction -w $("In-put-St-ring" |tr -d -)
-ash: In-put-St-ring: not found
myfunction: option requires an argument -- 'w'
and... a few more.
I'm sure it's simple for someone with more bash experience than me, but I'm stumped. Thanks for your help!
Does your function honor the
--
option, to "Delimit the option list"? – Xen2050 – 2019-03-16T04:37:37.463