Skip to content

Instantly share code, notes, and snippets.

@mjm522
Created November 18, 2021 15:49
Show Gist options
  • Save mjm522/f35ffd3d1b913702f245e49a6c1d7b1c to your computer and use it in GitHub Desktop.
Save mjm522/f35ffd3d1b913702f245e49a6c1d7b1c to your computer and use it in GitHub Desktop.
A bash file to read line by line from a file and the split the line to words using space as a delimiter.
#!/usr/bin/bash
input="full path to file"
while IFS= read -r line; do
arrIN=(${line// / }) ## to split with ; arrIN=(${line//;/ })
## do something with the words, words can be obtained by ${arrIN[i]} where i is the index
done < "${input}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment