0

for example:

I hope to get names of all the files contains

start on startup 

in /etc/init.

Yishu Fang
  • 9,448
  • 21
  • 65
  • 102

2 Answers2

2

You could try the below grep command,

$ cd /etc/init
$ grep -l "start on startup" *

OR

Through a single command,

$ grep -l "start on startup" /etc/init/*

From man grep,

-l, --files-with-matches  print only names of FILEs containing matches
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
2

I believe the following should do the trick:

grep -ls 'start on startup' /etc/init/*

This will grep through all files in your /etc/init directory and print out only the filenames while also omitting any errors (i.e. /etc/init/<dir_name> is a directory).

Here is a post that explains the -l option: grep-show-just-filenames

Here is another post that explains the -s option: grep-omit-file/directory-errors

Community
  • 1
  • 1
Zhouster
  • 746
  • 3
  • 13
  • 23