-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
content/posts/2024-12-09-bash-glob-hidden-files-recursively.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: "bash: glob hidden files recursively" | ||
date: 2024-12-09T17:53:14-03:00 | ||
tags: | ||
- dev | ||
- devops | ||
--- | ||
|
||
Assume you make a huge change to your git repository, that spawns several file | ||
formats – cpp, java, javascript, python, etc. | ||
|
||
In the end you want to revert the javascript changes, for the sake of splitting | ||
your commit into self-contained chunks[^1]. | ||
|
||
I like the following approach[^2]: | ||
|
||
```shell | ||
% git checkout -- **/*.js | ||
``` | ||
|
||
**Caveat**: It does not include hidden files, or files in hidden directories. | ||
Unless...you set the `dotglob` option: | ||
|
||
```shell | ||
% shopt -s dotglob | ||
``` | ||
|
||
Note that `shopt` works in `bash`, alas not in `zsh`. | ||
|
||
|
||
[^1]: https://sscce.org/ | ||
[^2]: In theory, this is a pre-requisite: `shopt -s globstar`. In practice, it | ||
should be the default behavior. | ||
|
||
<!--more--> |