Prepare for your Next Interview
This is a discussion on Math Calculations - Unix Shell within the Unix/Linux forums, part of the Operating Systems category; Can someone tell me how to do the following inside a unix script? I have a file and can do a wc -l on it....say the count is 123 ...
|
|||
|
Math Calculations - Unix Shell
Can someone tell me how to do the following inside a unix script?
I have a file and can do a wc -l on it....say the count is 123 lines. #wcl /tmp/file >123 I would then like to divide this number by 2 to get a decimal number. # wcl /tmp/file| `expr /tmp/file /2` Can't find the right expr combo. Any idea how to accomplish this? Thx. Kurt |
| Sponsored Links |
|
|||
|
Re: Math Calculations - Unix Shell
ur approch is right but u need to change some thing
as wc -l does not only returns file rows it also return file name so that name can not be divided so use cut to remove that file name also make sure in expr there should be space around arithmetic operator |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Submit a concurrent program from a Unix Shell Script | sunil_sadige | Oracle Apps | 1 | 02-07-2008 08:32 AM |
| Math Matrix in C++ | The Professional | C and C++ | 0 | 12-04-2007 03:36 AM |
| Aston Shell is a powerful, fast, stable and flexible shell replacement application. | JobHelper | Geeks Lounge | 0 | 09-21-2007 03:11 AM |
| About Shell Layer Management in UNIX | nancyphilips | Unix/Linux | 2 | 12-14-2006 07:51 AM |
| Difference in UNIX Shell | scott | Unix/Linux | 2 | 07-23-2006 11:40 AM |