Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash: resample the lines of a multiline variable
function resample() {
sample_interval=$1
fh=$2
ctr=1
while read line; do
[[ $sample_interval -eq $ctr ]] && echo "$line" && ctr=0
((ctr++))
done < <(echo "$fh")
}
resample 60 "$file_var"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment