bash - How to set my regex to return in only one line? -


my input information can be: "abc1-abc-ab-0/1/2" or "abc1-abc-0/1/2". need return variable in 1 line. in regex code, i'm gettint 2 lines of maches. can me?

[root@server]# echo "abc1-abc-ab-0/3/7" | grep -op '^(([a-za-z0-1]){4})-(([a-za-z]){3})|-(([a-za-z]){2})'  abc1-abc -ab 

two ways collect output of command on 1 line:

echo $( command )  command | xargs echo 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -