Results 1 to 3 of 3
  1. #1
    Join Date
    May 2011
    Posts
    319

    Question [Bash Script] How to set up redirect of script output within script

    Hello,

    I know if I would like to redirect all output of a bash script to an external file, I can run it as script.sh>output.txt

    However, I am just wondering if it would be possible for me to set up the script so that if I run ./script.sh, it will automatically create a file called output.txt, put all the results there?

    Thanks!
    96MB.com
    Low-end VPS review blog running on 96MB of RAM

  2. #2
    Join Date
    Apr 2003
    Location
    Los Angeles, CA
    Posts
    820
    This should work

    Code:
    #!/bin/bash
    (
    original
    commands
    here
    ) > output.txt
    Pings <1 ms, Unlimited Transfer, Lowest Price: http://localhost/

  3. #3
    Join Date
    May 2011
    Posts
    319
    Thanks a lot!
    96MB.com
    Low-end VPS review blog running on 96MB of RAM

Similar Threads

  1. Extracting a username from bash script output.
    By ZKuJoe in forum Programming Discussion
    Replies: 3
    Last Post: 02-17-2010, 06:00 AM
  2. Can .htaccess call a script (e.g. a bash .sh script)?
    By Kadence in forum Hosting Security and Technology
    Replies: 7
    Last Post: 03-26-2008, 03:59 PM
  3. Replies: 14
    Last Post: 06-08-2006, 08:41 PM
  4. bash script
    By Dmitry85 in forum Programming Discussion
    Replies: 2
    Last Post: 04-10-2006, 04:39 PM
  5. bash comman/bash script
    By getbusy in forum Hosting Security and Technology
    Replies: 2
    Last Post: 12-25-2004, 06:50 PM

Tags for this Thread

Posting Permissions

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