doskey dirsize=du -P -c -a -b $1 $b grep -E "total$" $b awk "{i=1;print \"Has \" $i \" bytes\"}"
Inside a doskey alias
the pipe character is $b
all instances of $1
will be replaced with the first argument in the call to the alias, so, the $1
inside the awk
command will be replaced during the alias parse and at execution time it will not be a reference to the argument
The usual solution to this problem inside a doskey
alias is to convert the $1
into something that will not interfere the command execution but avoids doskey parser to handle it. To do it, the usual solution is to use $^1
, but in this case, this sequence is not handled by cmd
, it is handled by awk
and the ^
is not considered a escape character.
We need to solve it inside awk
, replacing the direct $1
using a variable (i
) to store the index to retrieve and replacing the $1
with $i
that has no special meaning inside doskey
aliases.