![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reattemps Calculation using awk | zanetti321 | UNIX for Advanced & Expert Users | 0 | 04-16-2008 03:13 AM |
| AWK equation evaluation. | srdgeo | Shell Programming and Scripting | 3 | 11-23-2007 09:10 AM |
| MD5 hash calculation | zedex | High Level Programming | 4 | 02-23-2007 11:37 PM |
| awk calculation | kekanap | Shell Programming and Scripting | 4 | 11-17-2006 04:39 AM |
| time calculation | liux99 | UNIX for Advanced & Expert Users | 2 | 08-18-2005 07:33 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
equation calculation on Unix
Hay, guys,
Any ideas how to calculate like this: in first file, there're number of lines listing 2+3, 6*9 ....... Then, how to get the result and put them in another file in format: 2+3 5 6*9 54 ...... sheerly by shell command, no scripts required. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
sed 's/\*/\\\*/' file1 > dummy
sed 's/\//\\\//' dummy > file2 while read line do echo "$line \c" >> Output echo "$line" | bc >> Output done < file2 |
|
#3
|
||||
|
||||
|
Code:
#!/bin/ksh
while read line
do
echo "${line} $(echo ${line} | bc)"
done < myFile.txt
|
|
#4
|
||||
|
||||
|
The way the question is phrased I tend to think that we may have homework rule violation here.
But: bc < input > temp ; paste input temp > output ; rm temp |
|
#5
|
|||
|
|||
|
Thanks Perderabo,
I think you answer is fairly enough. vgersh99&justsam's genius work is also appreciated. |
|||
| Google The UNIX and Linux Forums |