Skip to content

Instantly share code, notes, and snippets.

@mrjk
Last active January 2, 2024 00:36
Show Gist options
  • Save mrjk/42c07a70fb65ee10f326dae1bf0f6f68 to your computer and use it in GitHub Desktop.
Save mrjk/42c07a70fb65ee10f326dae1bf0f6f68 to your computer and use it in GitHub Desktop.
Snippets for bash

Iterations

Loop line over lines, whatever spaces in it:

while IFS= read -r line; do
    echo "... $line ..."
done < <(printf '%s' "$list")

Same, but with a variable:

while IFS= read -r line; do
    echo "... $line ..."
done <<< "$MY_TEXT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment