If multiple delimiters are present in a string then the below technique can be used to take the required word
Lets say I need to get the word mango.Then
>echo "apple,orange mango-strawberry" | sed 's/[ ,-]/|/g' | cut -d"|" -f1
mango
Use the sed to convert every delimiter to a same one.Use regular expression to convert it in sed.Then cut the required word.
Comments
Post a Comment