$ echo "./some_script" | awk 'gsub(".","a") {print $0}'
aaaaaaaaaaaaa
But must be:
$ echo "./some_script" | awk 'gsub(".","a") {print $0}'
a/some_script
> $ echo "./some_script" | awk 'gsub(".","a") {print $0}'
> aaaaaaaaaaaaa
>
> But must be:
>
> $ echo "./some_script" | awk 'gsub(".","a") {print $0}'
> a/some_script
Not so. The first argument of gsub is interpreted as a regular
expression, and "." in a regular expression means "any character".
Consequently, all characters in the input are replaced. You must use
"\." to match a literal dot.
> $ echo "some_script" | awk 'gsub("/","a") {print $0}'
> $
>
> But must be:
>
> $ echo "some_script" | awk 'gsub("/","a") {print $0}'
> $ some_script
Also not the case. You have placed the call to gsub into the pattern
part of the pattern-action statement. Consequently, it evaluates to 0
because there are no slashes in the input, and therefore the action is
never executed. A correct action statement would be
{gsub("/", a); print $0}
--
A rabbi whose congregation doesn't want John Cowan
to drive him out of town isn't a rabbi, http://www.ccil.org/~cowan
and a rabbi who lets them do it co...@ccil.org
isn't a man. --Jewish saying