Skip to content

Instantly share code, notes, and snippets.

@hackugyo
Created June 16, 2015 03:14
Show Gist options
  • Select an option

  • Save hackugyo/98b5704e51607809ab53 to your computer and use it in GitHub Desktop.

Select an option

Save hackugyo/98b5704e51607809ab53 to your computer and use it in GitHub Desktop.
bashの履歴展開が,agに渡したい正規表現の否定先読みと衝突する
# 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