Print some results in a text file using script in linux


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print some results in a text file using script in linux
# 1  
Old 02-27-2011
Question 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.
# 2  
Old 02-27-2011
You must show what you have done to solve the problem by your own.
Furthermore, this is the wrong forum for this problem.
Read here
# 3  
Old 02-27-2011
Use printf for the basic formatting, eg somthing like this:

Code:
DID=TestID
DDATE=$(date +%Y-%m%d)
DTASK1="Testing"
DRESULT1=OK
DTIME1=$(date +%T)
printf "XYZ test results\n"
printf "\n"
printf "ID: %-20sDate: %s\n" $DID $DDATE
printf "%s\n" "-------------------------------------------------"
printf "|%-14s| %-10s| %-10s |\n" Task Result Time
printf "%s\n" "-------------------------------------------------"
printf "|%-14s| %-10s| %-10s |\n" "$DTASK1" "$RESULT1" "$DTIME1"
printf "%s\n" "-------------------------------------------------"
printf "\n"
printf "AD No: %-20sGenerated Date: %s\n" ADN001 "$(date +%m-%d-%Y)"

This User Gave Thanks to Chubler_XL For This Post:
# 4  
Old 02-28-2011
MySQL Thanks

Quote:
Originally Posted by Chubler_XL
Use printf for the basic formatting, eg somthing like this:

Code:
DID=TestID
DDATE=$(date +%Y-%m%d)
DTASK1="Testing"
DRESULT1=OK
DTIME1=$(date +%T)
printf "XYZ test results\n"
printf "\n"
printf "ID: %-20sDate: %s\n" $DID $DDATE
printf "%s\n" "-------------------------------------------------"
printf "|%-14s| %-10s| %-10s |\n" Task Result Time
printf "%s\n" "-------------------------------------------------"
printf "|%-14s| %-10s| %-10s |\n" "$DTASK1" "$RESULT1" "$DTIME1"
printf "%s\n" "-------------------------------------------------"
printf "\n"
printf "AD No: %-20sGenerated Date: %s\n" ADN001 "$(date +%m-%d-%Y)"

Thank you so much for this idea.. OMG i can't believe it was that simple... Smilie

Again thank you so much for your response...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a text file and a pdf file from Linux command results.

Hello. The task : Using multiple commands like : gdisk -l $SOME_DISK >> $SOME_FILEI generate some text file. For readiness I must insert page break. When the program is finished I want to convert the final text file to a pdf file. When finished, I got two files : One text file and One pdf... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies

3. UNIX for Beginners Questions & Answers

Print a python script down a list in a text file without printing a lot combinations

In a python script I have 2 files printing side by side on the same line. I want to have 1 of the files to be already displayed at once while the other file print down the list in the file and it still will produce new lines. I want to do it like that to reduce printing a lot of lines and... (0 Replies)
Discussion started by: bigvito19
0 Replies

4. UNIX for Dummies Questions & Answers

Reading XML file and print the values in the text file using Linux shell script

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (1 Reply)
Discussion started by: sravanreddy
1 Replies

5. Shell Programming and Scripting

Script template for inputting filenames and print results

Hi, Hope you are all well. New to scripting, and all those characters are all a new language for me. Though hoping to get my little head round it all sooner or later. I was wondering whether anyone could help with a script template example. What I would like to happen is to run the script... (8 Replies)
Discussion started by: loky27
8 Replies

6. Shell Programming and Scripting

shell script to print particular column into text file

hi everyone, i need a script which would just print column into a text file nmap 10.226.112.222 PORT STATE SERVICE 7/tcp open echo 13/tcp open daytime 22/tcp open ssh 23/tcp open telnet 37/tcp open time 1100/tcp open unknown above nmap command gives us open ports on that IP. can... (6 Replies)
Discussion started by: anand121
6 Replies

7. Shell Programming and Scripting

print first few lines, then apply regex on a specific column to print results.

abc.dat tty cpu tin tout us sy wt id 0 0 7 3 19 71 extended device statistics r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device 0.0 133.2 0.0 682.9 0.0 1.0 0.0 7.2 0 79 c1t0d0 0.2 180.4 0.1 5471.2 3.0 2.8 16.4 15.6 15 52 aaaaaa1-xx I want to skip first 5 line... (4 Replies)
Discussion started by: kchinnam
4 Replies

8. Shell Programming and Scripting

Linux script - Crazy results

Here is my script: # # Capture the current directory. export -p CurrentDir="`pwd`" echo $CurrentDir # # Capture the new directory name in the form YYYYMMDD. export -p DateDir="`date +"%Y%m%d"`" echo $DateDir # # Store the desired target directory. export -p... (6 Replies)
Discussion started by: imprimisxo
6 Replies

9. Shell Programming and Scripting

search file and print results with shell script

input file 1.<CRMSUB:MSIN=0100004735,BSNBC=TELEPHON-9814060328-TS11&TS21&TS22,NDC=9814,MSCAT=ORDINSUB,SUBRES=ALLPLMN-SPICE,BAOC=OIC,BAPRC=INFO,ACCSUB=BSS,NUMTYP=MULTI;... (3 Replies)
Discussion started by: dodasajan
3 Replies
Login or Register to Ask a Question