subtraction a list of number
hi guys
i have a file which list some numbers this file is like Quote:
i wrote a for loop Quote:
how can i solve this problem |
Hi,
Try this: Code:
for i in $(cat number.txt ); do let i=i-1 ; echo $i ; done Hope this helps. |
Quote:
|
Hi,
Quote:
Code:
$ cat number.txt |
Solved?
What did you do to accomplish that (might be of interest for people that stumble upon this thread). |
Just as slight alternative:
Code:
for i in $(< number.txt);do echo $((--i));done |
Please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
Don't Read Lines With For. You should almost always use a while+read loop instead when working with files or the output of commands. One possibility it's failing could be line endings. If the file was created on a Windows machine, it will have dos-style cr+lf line endings, instead of unix-style lf-only line endings, and the extra carriage return could be messing it up. This is particularly true in an arithmetic context, since anything not an integer would break syntax. The output of file will tell you if it has crlf line endings. If so, there are many options for fixing them, such as tofrodos. Google or LQ search it. |
Quote:
|
Let me just look up my crystal ball to help solve that error???
|
All times are GMT -5. The time now is 05:08 AM. |