LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-27-2011, 08:44 PM   #1
viriimind
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Rep: Reputation: 0
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.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-27-2011, 10:10 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
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
 
2 members found this post helpful.
Old 02-28-2011, 04:24 AM   #3
viriimind
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Original Poster
Rep: Reputation: 0
I am just going to use printf for this now.. Thanks for your response.
 
Old 02-28-2011, 12:00 PM   #4
soplin
Member
 
Registered: Apr 2007
Distribution: Mostly Debian
Posts: 114

Rep: Reputation: 19
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Save the results of a fortran loop in a text file simpleman0982 Programming 2 11-02-2010 11:40 PM
[SOLVED] Output to a text file, the results of compound command Herbivore Linux - General 5 07-28-2010 10:38 AM
Running make menuconfig results in text file is busy. jerel4565 Linux - Kernel 2 07-18-2009 10:40 PM
bash script to create text in a file or replace value of text if already exists knightto Linux - Newbie 5 09-10-2008 11:13 PM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration