[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: config files - newline possible?



On Thu, Apr 11, 2024 at 05:56:05PM +0200, Hans wrote:
> Hi folks, 
> 
> O know in shell scripts it is possible, to seperate a looong line of commands 
> into several short lines.
> 
> But can this be done in config-files, too?
> 
> I have a files with the syntax like this:
> 
> Do_not_write="/path1/subfolder /path1/subfolder2 ... /pathX/subfolderX"

As Nicolas George says, "config-file" is too generic a term.
If the above is a variable assignment, then you can escape the
newlines with a backslash, like so

Do_not_write="path1/subfolder \
  path1/subfolder2 \
  ..."

Note that the backslash has to be the last character in the
line. No extra whitespace after that (this is somewhat
fragile). I prefer to put such things in here docs:

read -d '' Do_not_write <<"__END"
this
that
the other
__END

echo "Do_not_write"
=>
this
that
the other

Put attention to the quotes. In bash, type "help read" to learn
about the options (it is a builtin, it has to).

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


Reply to: