knl
knl

Reputation: 1051

Docker compose failed while building Django app because of "grep -v" with trailing \r

I'm trying to compose up a docker-compose file and there is one step where I ran grep -v '^#' .env to get all the uncommented lines from .env file to set environment variables.

In the .env file, it looks like this

DB_ENGINE=django.db.backends.postgresql

However, after running grep -v '^#' .env and I check the environment, variable DB_ENGINE has value of "django.db.backends.postgresql\r" (notice the trailing \r there).

How can I overcome this? I've been doing this for a long time and it has never happened before.

Upvotes: 2

Views: 74

Answers (1)

VonC
VonC

Reputation: 1327784

Without trying a dos2unix on all your files, you could simply remove any \r from your grep result, as in here, with:

grep -v '^#' .env| tr -d '\r'

Upvotes: 1

Related Questions