how to delete filename from string with absolute path using sed?
Hello, everyone!
I have the following problem. I've a file containing lots of similar string, actually they are a paths to files. I need to remove the filename from it. Just can't figure out how to do that. So, for clearance, there is an example input file in1: Code:
./.VirtualBox/Machines/eData/Logs/VBox.log Code:
./.VirtualBox/Machines/eData/Logs/ I've tried to do so to guess inverse sed s/\\/.*$// in1, but that leads only to the following output: Code:
. |
have you tried using dirname?
in sed you can have Code:
sed 's/[^\/]\+$//' in1 Code:
while read LINE; do |
Thanks a lot! How could i forgotten about dirname?! ) That did exactly what I needed.
But never the less, I've tested sed 's/[^\/]\+$//' in1, that worked just the same. Though, I have not succeeded with sed 's@[^/]@\+$@', the output is: Code:
+$/.VirtualBox/Machines/eData/Logs/VBox.log |
All times are GMT -5. The time now is 12:52 AM. |