I've been given this one-liner to know how much memory my processes consume.
$ ps -u $USER -o pid,rss,command | \
awk '{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}'
Now I'd like to create an alias for that command, but have an issue escaping '
characters:
$ alias mm=ps -u $USER -o pid,rss,command | \
awk '{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}'
bash: alias: -u: not found
bash: alias: myuser: not found
bash: alias: -o: not found
bash: alias: pid,rss,command: not found
Total 0 MB
I tried to escape the single quotes, but still it doesn't work.
$ alias mm='ps -u $USER -o pid,rss,command | \
awk \'{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}\''
>
Can you help me understand how to create this alias?