grep(1) -q '^option' file && sed(1) -i 's/^option.*/option=value/' file || echo.1posix 'option=value' >> file
print lines matching a pattern
-q, --quiet, --silent
       Quiet; do not write anything to standard output.  Exit immediately with zero status if  any  match
       is  found,  even  if  an  error  was  detected.   Also see the -s or --no-messages option.  (-q is
       specified by POSIX.)
grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus
(-) is given as file name) for lines containing a match to the given PATTERN.  By  default,  grep  prints
the matching lines.
AND and OR lists are sequences of one of more pipelines separated by the &&  and  ||  control  operators,
respectively.  AND and OR lists are executed with left associativity.  An AND list has the form

       command1 && command2

command2 is executed if, and only if, command1 returns an exit status of zero.

An OR list has the form

       command1 || command2

command2  is  executed  if and only if command1 returns a non-zero exit status.  The return status of AND
and OR lists is the exit status of the last command executed in the list.
stream editor for filtering and transforming text
-i[SUFFIX], --in-place[=SUFFIX]

       edit files in place (makes backup if extension supplied)
If no -e, --expression, -f, or --file option is given, then the first non-option argument is taken as the
sed script to interpret.  All remaining arguments are names  of  input  files;  if  no  input  files  are
specified, then the standard input is read.
write arguments to standard output
Before a command is executed, its input and output may be redirected using a special notation interpreted
by  the  shell.   Redirection  may  also  be used to open and close files for the current shell execution
environment.  The following redirection operators may precede or appear anywhere within a simple  command
or may follow a command.  Redirections are processed in the order they appear, from left to right.

Appending Redirected Output
    Redirection of output in this fashion causes the file whose name results from the expansion of word to be
    opened  for  appending  on  file  descriptor  n,  or  the standard output (file descriptor 1) if n is not
    specified.  If the file does not exist it is created.

    The general format for appending output is:

           [n]>>word
source manpages: grepsedecho