LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Print some results in a text file using script in linux (https://www.linuxquestions.org/questions/linux-newbie-8/print-some-results-in-a-text-file-using-script-in-linux-865374/)

viriimind 02-27-2011 08:44 PM

Print some results in a text file using script in linux
 
hello everyone,
i really need your help to write a script which would just print following kind of result into a text file (result.txt)

Code:

XYZ test Results

ID: <unique-id>                Date: <date>

-------------------------------------------------
| Task        | Result    | Time      |
-------------------------------------------------
| <task1>      | <Result1> | <time1>  |
|              |          |          |
-------------------------------------------------

AD No: <adn>              Generated Date: <tdate>


above all the values of <something> are dynamic or predefined.


Please, kindly help to with this issue... Thanks in advance.

chrism01 02-27-2011 10:10 PM

Just about any programming lang COULD do that, it's your choice... Personally I'd probably use Perl.
http://perldoc.perl.org/
http://www.perlmonks.org/?node=Tutorials

viriimind 02-28-2011 04:24 AM

I am just going to use printf for this now.. Thanks for your response.

soplin 02-28-2011 12:00 PM

Code:

echo "ID: $1              Date: $2 /n/n

-------------------------------------------------/n
| Task        | Result    | Time      |/n
-------------------------------------------------/n
| $3          | $4        | $5        |/n
|              |          |          |/n
-------------------------------------------------/n/n

AD No: $6              Generated Date: $2  "

You can start with some simple bash like this and perhaps combine sed and gawk.
Then you sh program.sh p1 p2 p3 p4 p5 p6 > result.txt
where p are the parameters or you can chmod a+x program.sh and just ./program.sh p1 p2 p3 p4 p5 p6 > result.txt

I get the feeling that this is homework.


All times are GMT -5. The time now is 04:20 PM.