The output of find command is like
/home/user/test/folder1/abc.png
Now i want to get
folder1
from above string
|
The output of find command is like
Now i want to get
from above string |
|||
|
|
|
Are you looking for that part of the path based on a fixed location from the left of the path or fixed depth from the right? If you are looking from the left you can do this easily with cut by using '/' as a field separator and grabbing the fourth field like this:
|
|||
|
|
|
If you want "folder1", then type "folder1" ... If you want the second-to-last path component, this works in both
(assuming |
|||
|
|
or, if you want to operate on the output of find (i.e. several paths, one per line)
|
|||||||||||
|
|
I would use awk. Something like:
|
||||
|
|