I am struggling with the following sample code:
array1=(a b c d)
array2=(* * * *)
print ${array1[2]}
print ${array2[2]}
It returns 'c' and the name of a file in the directory I'm in.
I can't for the life of me work out how to prevent the shell interpreting the '*' and just get it to return the plain character ... is there a way to do this?
Also, my Learning the Korn Shell book lists several sed-like functions you can use to edit variable names, e.g.
variable=string
variable=${variable/g/gs}
print $variable
returns 'strings'. But Sed has a function where you can 'store' part of the pattern matched, and get it back in the replacement string, e.g.
print $variable | sed "s/\(strin\)g/\1/"
returns 'strin'. Does the Korn shell have a similar feature that's not in my book?