I have a python script that outputs a long list of files.
The script is ran from bash, and at the end i need to assign the last three files each to a specific variables.
I'm able to capture the output into a bash Variable, but then when I try to pipe it to 'tail' command, it seems to be one line only?
I've tried tips i've seen around, but can't seem to figure out how to work on an individual line basis with output.
it seems that any python output will be interpreted as one line?
echo "TESTING sample multi-line python output"
OUTPUT=$(python -c "for i in range(5): print(i)")
# check output
echo "$OUTPUT"
variable3=$(echo $OUTPUT | tail -1)
echo "VARIABLE CAPTURED"
echo $variable3
But I actually need to capture variable1 as 3rd line from end, variable2 as 2nd line from end and variable3 as first line from the end
So that in the above example at the end the desired result is:
variable1 = 2
variable2 = 3
variable3 = 4
in order to pass these variables to next stage of the script...