I'm trying to run the following:
x=$(echo "$1" | egrep -c "^[0-9]|[:&^]")
Now, this code is supposed to look for a word that 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.
尝试这个
echo "$1" | nawk '{for(i=1;i<=NF;i++){ if($i ~/^[0-9]|[:&^]/ ){c++;}}}END{ print "count:"c}'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.