3

I have a list of java reserved words, first letter capitalised.

$ tail -n5 ~/reservedjava.txt
Break
While
True
False
Null

I'm trying to look through all my java source code to find methods that look like getWhile().

cat ~/reservedjava.txt | parallel 'ag "get{}\(\)$"'

This shows me nothing. Now, I know that I have a method getBreak():

$ ag "getBreak\(\)$"
src/main/java/Foo.java
154:  public Break getBreak()

Here's what a dry run looks like:

$ cat ~/reservedjava.txt | parallel --dry-run 'ag "get{}\(\)$"' | tail -n5
ag "getBreak\(\)$"
ag "getWhile\(\)$"
ag "getTrue\(\)$"
ag "getFalse\(\)$"
ag "getNull\(\)$"

I'm using gnu parallel (v. 20130722) and the silver searcher (ag) (v. 0.18.1). If it makes a difference, I'm on Fedora 19, but have compiled these utilities myself. I get the same result with ack (v. 2.12).

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
djeikyb
  • 348
  • 1
  • 10

1 Answers1

3
cat ~/reservedjava.txt | parallel 'ag "get{}\(\)$"'

This doesn't work because ag wants a path argument. Eg, search where.

This works, recursively search starting at the current directory:

cat ~/reservedjava.txt | parallel 'ag "get{}\(\)$" ./'
djeikyb
  • 348
  • 1
  • 10