Skip to content

Instantly share code, notes, and snippets.

@binarytemple
Created August 7, 2014 21:15
Show Gist options
  • Select an option

  • Save binarytemple/6d43a3a41d444bcc09bb to your computer and use it in GitHub Desktop.

Select an option

Save binarytemple/6d43a3a41d444bcc09bb to your computer and use it in GitHub Desktop.
zsh - strip everything from a path except the base directory name
Path
```
i=.`/riak.logs.cloudstoragea08/2014-08-07T15:47:49.540310/console.log.2014-07-31-05
```
Extract the base directory name
```
echo ${${i:2}%%/*}
```
Result
```
riak.logs.cloudstoragea08
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment