Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, I am using system() command to save command output in txt file and i am storing in one character variable. for example Code: system("ls>output.txt"); but what should i do ...
  1. #1
    Linux User
    Join Date
    Aug 2008
    Location
    Trichy,India
    Posts
    308

    saving output in file

    Hello,
    I am using system() command to save command output in txt file and i am storing in one character variable. for example
    Code:
    system("ls>output.txt");
    but what should i do when i have to save another one command output in the same txt file continuously, for example
    Code:
    system("ls>output.txt");
    system("lsmod>output.txt");
    the output of these 2 commands should come in one txt file continously it should get over write.
    Thanks in advance...

  2. #2
    Linux Newbie
    Join Date
    Dec 2009
    Posts
    241
    > Means write in the file, create if it doesn't exist
    >> Means append to file, create if it doesn't exist

    So just write:
    Code:
    system("ls>output.txt");
    system("lsmod>>output.txt");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...