Cut all characters after last match using SED

# echo "xxx/xxxx/xxxxx/yyy" | sed 's|\(.*\)/.*|\1|'
# echo "xxxx/x/xx/xx/xxxx/x/yyyyy" | sed 's|\(.*\)/.*|\1|'

Output

xxx/xxxx/xxxxx
xxxx/x/xx/xx/xxxx/x
This entry was posted in Command Line FU and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *