-1

`clear echo "testing calc" date echo -e "======================================" yc1=0 yc2=0 yc3=0 lol=0 tnd=0 lno=0 c1=0 c1b=0 c2=0 c2b=0 c3=0 c3b=0 bb=12 wt=100 con=768 rip=0 sw=0 echo "" echo "" echo -n "Please Enter Lot no. = " read lno

numeric=0; while [ $numeric -eq 0 ] ; do read -p "Please Enter Total Ends = " tnd ; if [[ $tnd =~ ^[0-9]+$ ]] ; then numeric=1 ; else echo "Error: No's Only, 4 Digits" ; fi ; done echo ""

numeric=0; while [ $numeric -eq 0 ] ; do read -p "Please Enter 1st Count = " yc1 ; if [[ $yc1 =~ ^[0-9]+$ ]] ; then numeric=1 ; else echo "Error: No's Only, 2 Digits" ; fi ; done

numeric=0; while [ $numeric -eq 0 ] ; do read -p "Please Enter Cones per Bag = " c1b ; if [[ $c1b =~ ^[0-9]+$ ]] ; then numeric=1 ; else echo "Error: No's Only, 2 Digits" ; fi ; done

numeric=0; while [ $numeric -eq 0 ] ; do read -p "Please Enter $((yc1))/s Count % = " c1 ; if [[ $c1 =~ ^[0-9]+$ ]] ; then numeric=1 ; else echo "Error: No's Only, 2 or 3 Digits" ; fi ; done

echo -e "$(($c1))% Ends for $((yc1))/s Count = $(($tnd * $c1 / $wt))" y1a=$(($bb * $c1 / $wt)) echo -e "No of Beam for $((yc1))/s Count = $y1a" echo -e "Ends per Beam = $((($tnd * $c1 / $wt) / ($bb * $c1 / $wt)))" y1b=$(($yc1 * $(($wt / $c1b)) * $con)) echo -e "Lenght of $((yc1))/s Count Cone = $y1b" echo "" ` This is part of a script. What I want is the output of the script should be saved on different directory in txt or pdf format in below mentioned form.

testing calculator

Sat Mar 5 02:44:16 EST 2016

Lot no. = 4566 Total Ends = 4800 Lenght of Lot = 12000

1st Count = 16
Count % = 100
Ends for Count = 4800
No of Beam = 12
Ends per Beam = 400
Lenght of Cone = 49152 Beams per Creel = 4 Creels Required = 3

Bags Required = 50

------------------ ------------------ Man. XXXXXXXX Man. XXXXXXX

  • I beleive that i asked too much from you guys. admit it ...... you cant handle this question. – Mudassir Mubin Baig Mar 06 '16 at 18:31
  • Your question is closed and therefore cannot be answered. In order for others to be able to answer the question, you'll need to request that it be reopened. However, note that it won't be reopened unless you've improved the question. Although you have edited the question, it still doesn't give anyone any more information about what you need, and would probably not be considered an improvement. Maybe an example or two would help for a start and maybe explain what part of redirecting to a file you don't understand. – garethTheRed Mar 06 '16 at 19:37

2 Answers2

1

Using the > redirect function, you can send the output of any script or command into a file at any location. By default, the file is created in the present working directory, but you can specify an absolute or relative path to the file if you wish:

/usr/local/bin/somescript.sh > /path/to/Documents/someprogram.log
DopeGhoti
  • 76,081
  • This is only creating an empty file to my desired location not the output of my script. – Mudassir Mubin Baig Feb 29 '16 at 08:19
  • That will be the case if your script is not producing any output. If you want to also capture standard error in addition to standard output, rather than > use > 2>&1. – DopeGhoti Feb 29 '16 at 17:59
0

For pdf you can send the output of you program to text2pdf <your script> | text2pdf -o <somepath-to-other-dir>/output.pdf