The following line works in tcsh shell when entered directly:
df -P . | awk -F: 'NR==2 {print "//"$1}' | awk '{printf "%s/%s\n", $0, ENVIRON["PWD"]}' | awk '{gsub("/home/", ""); gsub("/", "\\"); print}'
But when I try to use in in .cshrc to create an alias:
alias foo " df -P . | awk -F: 'NR==2 {print "//"$1}' | awk '{printf "%s/%s\n", $0, ENVIRON["PWD"]}' | awk '{gsub("/home/", ""); gsub("/", "\\"); print}' "
the outermost double quotes seem to be breaking things:
> foo
awk: cmd. line:1: {printf %s/%sn, /usr/bin/tcsh, ENVIRON[PWD]}
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: {gsub(/home/, ); gsub(/, \); print}
awk: cmd. line:1: ^ syntax error
awk: cmd. line:1: {gsub(/home/, ); gsub(/, \); print}
awk: cmd. line:1: ^ 0 is invalid as number of arguments for gsub
I have tried multiple combinations of quotes (following info here) with no success. What am I missing?
Figured out this quoting abomination:
The key was to replace: