I hope someone has an idea about my issue.
The current minimal example fails, if I'm trying to assign a command/pipeline output to a variable due to the grep "[[:space:]]"
expression for bash in the strict mode.
#/bin/bash
set -euo pipefail
egrep -v '>' file | grep "[[:space:]]" | wc -l
var=`egrep -v '>' file | grep "[[:space:]]" | wc -l`
echo $var
var=$(egrep -v '>' file | grep "[[:space:]]" | wc -l)
fails as well. I'm out of ideas.
file
? What are you expecting to happen, and what happens instead? Note that there appears to be a typo in your shebang line (should be#!
not just#
). – steeldriver Aug 25 '21 at 15:16var=$( { grep '[[:space:]]' file | wc -l || : ;} )
or simplervar=$( { grep -c '[[:space:]]' file_no_space || : ;} )
- see for example Prevent grep from exiting in case of nomatch – steeldriver Aug 25 '21 at 22:28