How to list variables declared in script in bash?

后端 未结 14 1030
走了就别回头了
走了就别回头了 2020-11-28 20:03

In my script in bash, there are lot of variables, and I have to make something to save them to file. My question is how to list all variables declared in my script and get l

14条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 20:29

    Based on some of the above answers, this worked for me:

    before=$(set -o posix; set | sort);
    

    source file:

    comm -13 <(printf %s "$before") <(set -o posix; set | sort | uniq) 
    

提交回复
热议问题