Hi
Can anybody tell me how can I dump the results of execution of a command into array form? For example, I want to execute:
and put each part of the result in an array element:
Thanks
Hi
Can anybody tell me how can I dump the results of execution of a command into array form? For example, I want to execute:
and put each part of the result in an array element:
Thanks
If your system supports process substitution:
IFS='\
' read -d'^Y' -a array < <(fdisk -l | grep 83 | grep Linux)
'^Y' is just a randomly chosen character that should not occur in the input data (entered using Ctrl-V Ctrl-Y).
If it doesn't support process substitution. Try this:
fdisk -l | grep 83 | grep Linux > /tmp/tempfile
IFS='\
' read -d'^Y' -a array < /tmp/tempfile