sed or awk delete after last slash
Hello,
How can I delete everything after the last slash of a line. For example form: /tmp/dir/test to: /tmp/dir Or from: /dir/tmp/dir/test To: /dir/tmp/dir I know how to delete everything before the last slash: sed 's!.*/!!' But how to do it after last the slash? |
use the "dirname" command instead, purpose made for exactly that.
|
sed 's%/[^/]*$%/%'
(Find "/", followed by any number of characters that are NOT "/", at the end of the line; Replace with "/") |
All times are GMT -5. The time now is 10:55 AM. |