I was wondering how I can make an alias in my.cshrc that will sum a column of my choosing of a file that I give it.
for example: if text.txt was:
a b 3
a c 2
b c 1
sumcolumn 3 text.txt
would return 6
I think that I can use::1 and?:2 for my user inputs right?
Here is what I am trying right now:
alias sumcolumn "awk \'{SUM+=\$\!:1}END{print SUM}\' \!:2"
I think I am not escaping something correctly. When I source my.cshrc I get a error:
Variable name must contain alphanumeric characters.
I have already manually tried using the awk command in the shell:
awk '{SUM+=$3}END{print SUM}' test.txt
and it works. What am I missing?
alias sumcolumn 'awk '\''{ k += $3 }END{print k}'\'''
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.