regex - sed path parsing is not working -


pwd | sed "s%^\(/[^/]*/\).*?\(/[^/]+\)$%\1...\2%"

i not sure why not work. have tried both greedy , non greedy star after first capture group. not using lookaheads or anything. works in regex testers. i'm trying grab first , last text-part of path (to squish while still providing idea of dir i'm in).

this tmux prompt line i'm kind of trying avoid bringing in heavyweight perl job.

why not use parameter expansions? parameter expansions cost way less processing power command, pipe , external command have there:

start="${pwd#/}"; start="${start%%/*}" end="${pwd/*\//}" printf '/%s/…/%s $ ' "$start" "$end" 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -