Find the answer to your Linux question:
Results 1 to 3 of 3
Hey guys, I need to save the output from my script into a new file. The output is just the content of two variables. My current code is #!/bin/bash echo ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    2

    [SOLVED] Save output

    Hey guys,

    I need to save the output from my script into a new file.

    The output is just the content of two variables.

    My current code is

    #!/bin/bash
    echo "Please enter 5 numbers"
    read num1
    read num2
    read num3
    read num4
    read num5
    add=`expr $num1 + $num2 + $num3 + $num4 + $num5`
    ans=`expr $add / 5`
    rem=`expr $add % 5`
    echo "The average of the 5 numbers is $ans with a remainder of $rem"


    I just need to store ans and rem.

    Any ideas?

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    Hi and Welcome !

    Redirect results to a file too.
    Code:
    echo "The average of the 5 numbers is $ans with a remainder of $rem" >> foo
    Check contents of foo.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Just Joined!
    Join Date
    May 2008
    Posts
    2
    XD really?

    So simple! Thank you!

Posting Permissions

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