-3

I have a Dockerfile with a lot of dependencies, it's very hard to see changes to the deps list in git diffs. How can i put every dependency on a new line using preferably substitute :s/?

Example:

RUN apt-get update && apt-get install -y --no-install-recommends \
    python3-pip rsync git tar make \
    gcc-9 g++-9 gfortran-9 \
    build-essential libssl-dev libegl-dev pkg-config \
    libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxaw7-dev \
    libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev \
    libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev \
    libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev \
    libxv-dev libxxf86vm-dev libxcb-render0-dev libxcb-render-util0-dev \
    libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev \
    libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev \
    libxcb-xinerama0-dev libxcb-dri3-dev uuid-dev libxcb-cursor-dev libxcb-util-dev \
    wget liblqr-1-0-dev sudo curl procps \
    clang-format-18 \
2
  • 1
    You mean like RUN apt-get update && apt-get install -y --no-install-recommends \ a_package \ b_package \ c_package \ ... one package per line in alphabetical order and so on? Commented Oct 1 at 8:20
  • @U880D yes exactly. Alphabetical order is not a requirement though Commented Oct 2 at 5:52

1 Answer 1

1

I could use sed with regexp to replace each space by \<CR> between each package in your list.

sed -E 's/^(\s)*//; s/ / \\\n/g;' Dockerfile
  • s/^(\s)*//: remove all leading spaces
  • s/ / \\\n/g: replace all spaces by \<CR>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.