Daniel Green <ddgr...@gmail.com> wrote: > I'm frequently searching CSV files with 20-30 columns, and when there's a > hit it can be hard to know what the columns are. An option to also print > the first line of a file (either always, or only if that file had a match > to the pattern) in addition to any hits would be nice. > > Thanks, > Dan
It sounds like awk would be a better tool: awk 'FNR == 1 || /pattern/' files ... should do the trick. HTH, Arnold