Search Results

Search: Posts Made By: Natalie
6,863
Posted By ctsgnb
You could check the value of $n like this (i...
You could check the value of $n like this (i guess you forgot what is in red below) :

n=$(sort /Users/Natalie/1/kuku.txt | tail -1)
echo $n
exitWhen you make sure the value is correct you can...
6,863
Posted By wisecracker
Here is a simple starter solution... ...
Here is a simple starter solution...
#!/bin/bash --posix
# num.sh
data="2013102100"
data1="${data:0:4}"
data2="${data:4:2}"
data3="${data:6:2}"
data4="${data:8:2}"
echo "$data1 $data2 $data3...
6,863
Posted By alister
In the future, to not waste anyone's time, please...
In the future, to not waste anyone's time, please mention in your problem statement that you are not interested in AWK solutions (or that you require a sh-only solution). This same issue occurred in...
6,863
Posted By Akshay Hegde
Sorry I was not knowing :)
Sorry I was not knowing :)
2,703
Posted By alister
While there may be combinations of AWK...
While there may be combinations of AWK implementation and operating system on which your suggestion is faster, I compared it against its predecessor on two combinations and yours was slower...
2,703
Posted By Jotne
This was very interesting, and an eye opener. I...
This was very interesting, and an eye opener. I have never tested this, just thought i many be solver to run ting in loop. This prove it many be wrong.
Thanks for taking time to test. :)
2,703
Posted By MadeInGermany
See my post in this forum...
See my post in this forum https://www.unix.com/shell-programming-scripting/237555-finding-average.html
At the end it divides the sum to find the average.
6,863
Posted By wisecracker
Longhand on OSX 10.7.5 default bash terminal:- ...
Longhand on OSX 10.7.5 default bash terminal:-
Last login: Thu Oct 10 07:41:49 on ttys000
AMIGA:barrywalker~> data=2013101173
AMIGA:barrywalker~> data1=${data:0:4}
AMIGA:barrywalker~> echo...
2,703
Posted By Jotne
I try to avoid loops in awk to speed things up. ...
I try to avoid loops in awk to speed things up. If you have gnu awk, you can do this:
awk '{a+=$1} END {print a}' RS=" |\n" file?
1779
If you like to store this into a variable do this:...
2,703
Posted By jethrow
script.ksh for num in `cat...
script.ksh
for num in `cat $*`;do((t+=num));done;echo $t
... or ...
awk '{for(i=1;i<=NF;i++)t+=$i} END {print t}' $*

echo 5 6 | sh script.ksh
Showing results 1 to 10 of 10

 
All times are GMT -4. The time now is 06:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy