#!/bin/bashstring='/abc/foo/../bar'sed -nE 's~^(/[^/]*)(/.*)?/\.\.(/[^/]*).*~\1\3~p' <<< "$string"
Standard input is empty
/abc/bar
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!