r - Using bash to transform a numeric sequence -
here vector of numbers have ascend (it called t8_
)
2 7 8 9 11 15 34 91 91 92 94
the problem number happen 2 times - don't want remove them have become 2 numbers unique , not floating point. thought @ first iterating through vector
the next vector be
2 7 8 9 11 15 34 91 92 92 94
then same process again
when vector be
2 7 8 9 11 15 34 91 92 93 94
for example works
#!/bin/bash while read -a vec; # int_min bash: 32-bit bash supports 64-bit integers. min=$((-1<<63)) ((i = 0; < ${#vec[@]}; i++)); (( min = vec[i] = vec[i] > min ? vec[i] : min + 1 )) done echo "${vec[@]}" done ###
the problem not real vector looks https://www.dropbox.com/s/vp67eiw4ns9rr07/num?dl=0.
when un.sh < vec
don't output in specific instance. tell me why?
i can't why shell code isn't working you, can offer perl solution works fine data
use strict; use warnings; use 5.010; use autodie; @numbers = split ' ', { open $fh, '<', 'num'; local $/; <$fh>; }; $i ( 1 .. $#numbers ) { ++$numbers[$i] if $numbers[$i] == $numbers[$i-1]; } "@numbers";
Comments
Post a Comment