2

Is it okay for me to check the contents of a file for a given string with grep in an init script?

I am concerned about introducing dependencies and general convention when it comes init scripts, and if running grep or other tools violates some credo.

mbrownnyc
  • 1,825
  • 8
  • 30
  • 50
  • supposedly you're supposed to use $() versus \`backticks\` now, but other than that I think you're good. Then again, backticks are more universal though ?deprecated?. Even the most stripped down versions of linux and linuxy OSs have grep. – MattPark May 15 '13 at 19:47
  • 1
    When I can do $(string expansion) on stackexchange, then I'll stop using `backticks`. :) – mbrownnyc May 16 '13 at 13:11

2 Answers2

6

iniscripts can do whatever they want. Of course it makes sense not to introduce new dependencies, just for the initscripts. grep however is fine on pretty much any system that's posix/susv3 compatible (linux, bsd, solaris, other derivatives).

For more utilities that should always be there, see http://pubs.opengroup.org/onlinepubs/009695399/idx/utilities.html

Dennis Kaarsemaker
  • 18,793
  • 2
  • 43
  • 69
1

In short, YES. So long as the file you are looking for is mounted at that point.

Magellan
  • 4,431
  • 3
  • 29
  • 53
mdpc
  • 11,698
  • 28
  • 51
  • 65