Open tamalsaha opened 4 years ago
while IFS= read -r line
do
echo "$line"
done < input_file
The internal field separator (IFS) is set to the null string to preserve leading and trailing whitespace which is the default behavior of the read command.
str="Learn to Split a String in Bash Scripting"
IFS=' ' # space is set as delimiter
read -ra ADDR <<< "$str" # str is read into an array as tokens separated by IFS
for i in "${ADDR[@]}"; do # access each element of array
echo "$i"
done
https://www.tutorialkart.com/bash-shell-scripting/bash-split-string/