UNIX "no match" error?
I'm trying to run the following:
x=$(echo "$1" | egrep -c "^[0-9]|[:&^]")
Now, this code is supposed to look for a word th开发者_StackOverflow中文版at starts with a number, or contains a :,& or ^. However,I geta "no match" error when I run this in UNIX. What makes matters more cofusing is that something similar runs well in terminal, but not in a script.
try this
echo "$1" | nawk '{for(i=1;i<=NF;i++){ if($i ~/^[0-9]|[:&^]/ ){c++;}}}END{ print "count:"c}'
精彩评论