Created
June 16, 2015 03:14
-
-
Save hackugyo/98b5704e51607809ab53 to your computer and use it in GitHub Desktop.
bashの履歴展開が,agに渡したい正規表現の否定先読みと衝突する
This file contains hidden or 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
| # Bash history expansion expands "!***" to a command! So you must use ag with regex in a script like this sample. | |
| # For example, $ag "^(?!.*sample).*$" returns "-bash: !.*sample: event not found" | |
| echo "Please pick me" | |
| echo "Please pick only me!" | |
| echo "sample 1" | |
| ag -G *.sh "^(?!.*sample).*$" #=> 3,4 | |
| echo "sample 2" | |
| ag -G *.sh "^.*(?!.*sample).*$" #=> (all lines) | |
| echo "sample 3" | |
| ag -G *.sh "only(?!.*sample).+$" #=> 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment