I need advice – how to print the same last value in ksh scripts without to print param argument
so what we can do in ksh inorder to print the last value ?
example – I need to print the last value ( in this case -$ETH_PORT ) , without to define $ETH_PORT parameter after the second echo command
how to print the last value from the last echo/print command?
function test
{
ETH_PORT=eth0
echo $ETH_PORT
# now I need to print the last value ( in this case value from $ETH_PORT param )
echo < what need to write in order to print last value >
}
test
expected output after runing the test function
eth0
eth0
You could subvert
echowith a function that kept track of the last thing echo’ed, but that wouldn’t capture the last thing to go tostdout:A second option is to use a wrapper script that keeps track of what the last line was and then print it at the end.