Hello,
I got following solution:
#!/bin/bash
filecount=0
for file in data*.ip
do
sed -i -n '382976, $p' $file
sed -i 's/[.]/,/g' $file
filecount=$(( filecount + 1))
echo $filecount
done
paste data*.ip > data.ip
cat data.ip | awk '{ printf("%.12f\n", ($1+$2+$3+$4+$5+$6+$7+$8+$9+$10+$11+$12+$13+$14+$15+$16+$17+$18+$19+$20+$21+$22+$23+$24+$25+$26+$27+$28+$29+$30+$31+$32+$33+$34+$35+$36+$37+$38+$39+$40+$41+$42+$43+$44+$45+$46+$47+$48+$49+$50+$51+$52+$53+$54+$55+$56+$57+$58+$59+$60+$61+$62+$63+$64+$65+$66+$67+$68+$69+$70+$71+$72+$73+$74+$75+$76+$77+$78+$79+$80+$81+$82+$83+$84+$85+$86+$87+$88+$89+$90+$91+$92+$93+$94+$95+$96+$97+$98+$99+$100)/100) }' > data.out
sed -i 's/[,]/./g' data.out
Its not really elegant, but it is working so far.
How can I do an easier average?
This is not really good as well:
sed -i -n '382976, $p' $file
sed -i 's/[.]/,/g' $file
How can i combine both? Tried it with the -e parameter, didnt work...
And how can I write to multiple seperate files, without the -i?
(data01.txt to data01_new.txt for example)
Isnt it possible to use parameters in sed?
Example:
#!/bin/bash
filecount=0
for file in data*.ip
do
sed -i -n '${1}, $p' $file
sed -i 's/[.]/,/g' $file
filecount=$(( filecount + 1))
echo $filecount
done
#!/bin/bash
row=${1}
filecount=0
for file in data*.ip
do
sed -i -n 'row, $p' $file
sed -i 's/[.]/,/g' $file
filecount=$(( filecount + 1))
echo $filecount
done
How can I cut row with sed from an defined row downwards?
And how can I paste rows after the cutting position?
(File1 has 1'000'000 row, I just want keep the first 300'000. File2 has 700'000 rows, I want paste these in File1 starting at position 300'001)
Thank you very much and a very nice weekend...
chillmaster