shell脚本在awk中非硬编码字符串

0 string bash shell awk

因此,为了编写特定用户的所有进程,我尝试使用此代码:

ps aux --sort -rss | awk '$1 == "$(whoami)"'
Run Code Online (Sandbox Code Playgroud)

当我将用户名硬编码到其中时,它完美无缺.此外,我试图用'',//和空格替换"",但它无论如何都不起作用.

Vik*_*lin 6

ps -u $(whoami) -o user,pid,%cpu,%mem,vsz,rss,tty,stat,start,time,comm --sort -rss

没有的方式 awk