Splitting a string in bash on something specific -
i had string cut based on colon. have string in format of: mon date, year birthday (input)
what can can have: mon date, year without birthday? (or in other words desired output of:)
mon date, year clarification: birthday in case literally string "birthday"
i know various posts on website tell how split strings based on delimiters, have no idea how split string based on specific word/string , couldn't find on here
with bash
orig="mon date, year birthday" val="${orig%% birthday}" echo $val mon date, year it's not splitting here, it's rather "stripping" off fix suffix. bash has built-in.
Comments
Post a Comment