In the shell is not strong, tell me how you can perform such an action using a script:

Save in the form of the ascii file F1.var the value of the internal variables of the shell and the number of processes in the system.

  • one
    Considering your next question , you are obviously undergoing some kind of testing. for you, it will be more useful for you to complete the test tasks yourself - aleksandr barakin

1 answer 1

Save environment variables:

printenv > F1.var 

Save processes to the same file.

 ps -aux >> F1.var 

I doubt if you need a script


Strictly speaking, the printenv command provides a list of environment variables, not internal shell variables, but I don’t really understand what benefits in this context can be obtained from $REPLY , $1 , $2 , $# variables and many others.

  • 2
    ps -axo pid , if you strictly follow the conditions of the problem :-) - PinkTux
  • @PinkTux if literally, then yes. And so, who knows what exactly is necessary there. - andy.37
  • four
    The answer to the first question is, of course, incorrect, but, given that, judging by the wording of the question, this is clearly some kind of test, so be it. - aleksandr barakin
  • @alexanderbarakin Is there a command that lists the currently installed internal shell variables? - andy.37
  • In fact, you just need to make a diff between the output of the "clean" environment and printenv. Since printenv displays the same environment, but which is formed after loading the shell, that is, adding its internal variables. - PinkTux