0

I trying write a program with bash file that create a text file then write the List of running programs file in the text file. I created a text file with bash that name is test.txt, how can I write List of running programs in the text file? I put my code here:

#!/bin/bash
cat test.txt
  • What exactly do you want to write into the file? The name of the script? The contents of the script? Something else? – choroba Jul 31 '20 at 13:22
  • I want write List of running programs in the text file – Sara Zahedi Jul 31 '20 at 13:25
  • 2
    Take a look at the answers to [this question](https://stackoverflow.com/questions/11162406/open-and-write-data-to-text-file-using-bash) and the man page for the command `ps`. – jirassimok Jul 31 '20 at 13:38

1 Answers1

0

To get a list of running programs, use ps. Run man ps for details.

To redirect the output of a command to a file, use >.

ps > test.txt

See REDIRECTION in man bash for details.

choroba
  • 231,213
  • 25
  • 204
  • 289