Question
Sometimes, you many want to list the folder(s) where contain specific file name. This time, you can leverage command find with argument '-name'
Sample code
Below sample code will look for all folders under specific path which contains '.jazz?' file (? can be any character):
Usage Example
First of all, let's check what we have under folder var using command tree:
And we want to find the folder which contains '.jazz?'. Let's use command find this way:
However, I only want '.jazz?' to exist under the exact depth=2 from var folder. Then we can do it this way:
Now the output is close to our expectation. Next step is to use command sed to remove out the '.jazz?':
Finally, you many want to list the folder with order in modification time, try this:
Sometimes, you many want to list the folder(s) where contain specific file name. This time, you can leverage command find with argument '-name'
Sample code
Below sample code will look for all folders under specific path which contains '.jazz?' file (? can be any character):
- findBuildDirs()
- {
- find $1 -maxdepth 2 -mindepth 2 -name '.jazz?' -type d | sed 's!/\.jazz[0-9]$!/!' | xargs -r ls -dt1
- }
Usage Example
First of all, let's check what we have under folder var using command tree:
And we want to find the folder which contains '.jazz?'. Let's use command find this way:
However, I only want '.jazz?' to exist under the exact depth=2 from var folder. Then we can do it this way:
Now the output is close to our expectation. Next step is to use command sed to remove out the '.jazz?':
Finally, you many want to list the folder with order in modification time, try this:
沒有留言:
張貼留言