Skip to content
Advertisement

How to add a word at the beginning of each line BUT not when a # is present

Given a file with many ENV variables.

Example: DEV.env

JavaScript

I know the command sed "s/^/export /g" will add export at the beginning of each line.

But I don’t want to do this when the first character is “#”.

How can I do with sed?

Advertisement

Answer

Something like this:

JavaScript

Alternatives:

JavaScript
Advertisement