Silver Searcher: how to return filename without path

ag

Solution

The l (lowecase L) flag will return the files-with-matches instead of the lines matched.

e.g.

`$ ag -l "angel"`

you can pipe into `sed` to remove anything up to and including the final `/` which leaves the filename.

`ag -l angel | sed 's=.*/=='`

Problem

I am using Silver Searcher to find information in my Calibre library which, by default uses long directory and filenames that are a bit redundant. Example search: ``` chris@ODYSSEUS:~/db/ebooks/paper-art$ ag --markdown angel Christophe Boudias (Editor)/Origami Bogota 2014 (Paginas de Origami) (2)/Origami Bogota 2014 (Paginas de Origami) - Christophe Boudias (Editor).md 8:* [16] Angel (???) 9:* [22] Christmas Angel (Uniya Filonova) Juan Fernando Aguilera (Editor)/Origami Bogota 2013 (Paginas de Origami) (1)/Origami Bogota 2013 (Paginas de Origami) - Juan Fernando Aguilera (Editor).md 29:* [96] Inspired Origami Angel (K. Dianne Stephens) 31:* [100] Angel for Eric Joisel (Kay Kraschewski) ``` I would like to return just the filename where the whole path is shown in the example. How can I do that?

Original source