I think I'm misunderstanding something about using read
in fish to extract multiline input. Here's my basic script:
~> ps -aux | grep python | awk '/anaconda2/ {print $2,$9}'
3113 10:11
6079 10:20
12266 14:06
14648 Apr01
23460 Apr01
23984 Apr01
25064 Apr01
27110 00:10
I want to read this into a single variable with read --list --line
, but instead I just get the first line of data:
~>
ps -aux | grep python | awk '/anaconda2/ {print $2,$9}' | read -l --list --line pids_starts
~> echo $pids_starts
3113 10:11
If I use read -z
I get all of values but they are split into individual variables:
~> ps -aux | grep python | awk '/anaconda2/ {print $2,$9}' | read -l --list -z pids_starts
~> echo $pids_starts
3113 10:11 6079 10:20 12504 14:13 14648 Apr01 23460 Apr01 23984 Apr01 25064 Apr01 27110 00:10
~> count $pids_starts
16
~> echo $pids_starts[1]
3113
How do I get each row of output set to a different array element with read
? I'd also believe that I'm misunderstanding how AWK delimits output, but I'm not certain.
Thanks!