i writing bash scripts , faced following problem. let's say:
function echo_ignore_print() { echo "ignoring print" # print line user without storing value value=187fef echo "$value" # return value } info_to_keep=$(echo_ignore_print) echo "$info_to_keep" # ignoring print 187fef
i need able print "ignoring print" script gets line need return value of variable "$value" itself, can use later on. rather not have global variables.
therefore, there way king of dump string of echo command , save later? or other way this?
thank help.
you can write to-be-ignored stuff on stderr
instead of stdout
:
echo_ignore_print() { echo "ignoring print" >&2 value='187fef' echo "$value" } info_to_keep=$(echo_ignore_print) ignoring print echo "$info_to_keep" 187fef
Comments
Post a Comment