Skip to content

Instantly share code, notes, and snippets.

@bassmanitram
Created March 28, 2025 10:33
Show Gist options
  • Save bassmanitram/ce4ddf880f2957ec5e2b81bb6637c9ae to your computer and use it in GitHub Desktop.
Save bassmanitram/ce4ddf880f2957ec5e2b81bb6637c9ae to your computer and use it in GitHub Desktop.
How to process each line of a BASH pipe without having to continuously recreate the "while read loop" for commands that can't!
# EXAMPLES
#
# docker ps -q | each-line.sh docker rm @L
# docker images -q | each-line.sh docker rmi @L
#
while IFS= read -r line; do
$(echo "$@" | sed "s/@L/$line/")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment