fork(1) download
  1. #!/bin/bash
  2.  
  3. for file in {1,2,3,4,5}.err; do
  4. {
  5. echo "IDK $RANDOM"
  6. echo "CSQ $RANDOM"
  7. echo "EDC $RANDOM"
  8. } > "/tmp/$file"
  9. done
  10.  
  11. VALUES=()
  12. while read -r LINE; do
  13. VALUES+=( "$( echo "$LINE" | sed 's/.*CSQ //')" )
  14. declare -p VALUES
  15. done < <(grep CSQ /tmp/*.err)
  16.  
  17. echo "Final (popen): "
  18. declare -p VALUES
  19.  
  20. echo
  21.  
  22. VALUES=()
  23. grep CSQ /tmp/*.err | while read -r LINE; do
  24. VALUES+=( ${LINE#*CSQ } )
  25. declare -p VALUES
  26. done
  27.  
  28. echo "Final (pipe): "
  29. declare -p VALUES
Success #stdin #stdout 0s 19656KB
stdin
Standard input is empty
stdout
declare -a VALUES=([0]="1729")
declare -a VALUES=([0]="1729" [1]="22170")
declare -a VALUES=([0]="1729" [1]="22170" [2]="17779")
declare -a VALUES=([0]="1729" [1]="22170" [2]="17779" [3]="27075")
declare -a VALUES=([0]="1729" [1]="22170" [2]="17779" [3]="27075" [4]="753")
Final (popen): 
declare -a VALUES=([0]="1729" [1]="22170" [2]="17779" [3]="27075" [4]="753")

declare -a VALUES=([0]="1729")
declare -a VALUES=([0]="1729" [1]="22170")
declare -a VALUES=([0]="1729" [1]="22170" [2]="17779")
declare -a VALUES=([0]="1729" [1]="22170" [2]="17779" [3]="27075")
declare -a VALUES=([0]="1729" [1]="22170" [2]="17779" [3]="27075" [4]="753")
Final (pipe): 
declare -a VALUES=()