bash sed into variable code example
Example 1: assign variable with sed not working
comp=$(echo "$fullName" | sed 's/ //g')
Example 2: bash sed output
Just use something like following with p option at sed command`s end:
cat file.txt| sed -En "s/string_to_replace/replacement_string/p"