How to remove the last dir with sed
(not dirname
), like this:
echo "/dir1/dir2/dir3/dir4" | sed .....
So I would get /dir1/dir2/dir3
.
Click on the path where you want the gap to start and again where you want it to stop. Then use the Direct Selection tool (A) to select the segment, and Delete to remove it. You could also use the Shape Builder Tool. First draw a shape like a circle over the path overlapping the segment you'd like removed.
There are two Linux commands you can use to remove a directory from the terminal window or command line: The rm command removes complete directories, including subdirectories and files. The rmdir command removes empty directories.
you don't have to use external tools
$ a="/dir1/dir2/dir3/dir4"
$ echo ${a%/*}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With