Skip to content

Instantly share code, notes, and snippets.

@rgpower
Created May 27, 2024 14:14
Show Gist options
  • Save rgpower/97ecd3cef373c55914d568ff62e368a3 to your computer and use it in GitHub Desktop.
Save rgpower/97ecd3cef373c55914d568ff62e368a3 to your computer and use it in GitHub Desktop.
capture directory contents as heredoc(s) - shallow
# first argument to scritpt is directory, for example /etc/apt/sources.list.d
# output looks like:
# cat > /etc/apt/sources.list.d/trivy.sources <<EOF
#Types: deb
#URIs: https://aquasecurity.github.io/trivy-repo/deb
#Suites: jammy
#Components: main
#Aarch: amd64
#Signed-By: -----BEGIN PGP PUBLIC KEY BLOCK-----
# .
# mQGNBFzP66QBDAC+sYojv+2L2wU7ZOjekt741t/Hz9mAR6rZfsFE8eOdK6Ozav2t
# l13QKpqSTUwQ33mQEwudEIUsZOov2tsBaG4r9Kxasu7wmeXoenvLWt92K6ZfcFwq
#...
# -----END PGP PUBLIC KEY BLOCK-----
#EOF
# ... more heredocs...
#
for x in $(ls $1); do printf "\ncat > $1/${x} <<EOF\n$(cat $1/${x})\nEOF\n"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment