Since you clarified what you wanted in a comment to Gnouc's answer, here's a solution:
sed 's|[^ /]*/|--|g'
$ echo '45mb ./aaaa/bbbb/cccc/dddd' | sed 's|[^ /]*/|--|g'
This will break if you have a trailing slash, or if the filepath you're passing to it contains any spaces. It would be pretty easy to script something a little more watertight, but it would involve more than a single line.
Here's one solution using capture groups:
sed -e 's|\([^ ]* \).*/\(.*\)|\1\2|'
|s as the separators because then I don't have to bother escaping the forward-slashes (but I would have to escape any
|s in the pattern). AFAIK
sed can have pretty much any character as a separator.
The first capture group
\([^ ]* \) matches 'any number of any character except a blank space, followed by a blank space'. The
.*/ matches 'any number of any characters, followed by a forward-slash', and the second group
\(.*\) captures 'any number of any characters'.
Sed's regular expressions (and most regular expressions) are greedy by default, so
.*/ will match the longest string that matches its pattern.
$ echo '45mb ./aaaa/bbbb/cccc/dddd' | sed 's|\([^ ]* \).*/\(.*\)|\1\2|'
However, this will break if there is a trailing slash:
$ echo '45mb ./aaaa/bbbb/cccc/dddd/' | sed 's|\([^ ]* \).*/\(.*\)|\1\2|'
This version will work even with a trailing slash, but will break if you have more than one:
sed -e 's|\([^ ]* \).*/\(.\)|\1\2|'
$ echo '45mb ./aaaa/bbbb/cccc/dddd/' | sed 's|\([^ ]* \).*/\(.\)|\1\2|'
$ echo '45mb ./aaaa/bbbb/cccc/dddd//' | sed 's|\([^ ]* \).*/\(.\)|\1\2|'