How to read lines from a file into an array in bash shell script

preview_player
Показать описание
In this tutorial we used while loop for reading lines of a file into an array.

Bash introduced mapfile and readarray in version 4 which can take the place of the while read loop. This tutorial is for older version of bash.

#simpleprogrammingsolution
Рекомендации по теме
Комментарии
Автор

That was a really great tutorial.. but I have a question what if I have data in file in pipe separated format how can we store that data in separate indices in array. For example My|name|is|ben. Now how can I store each word in new index. Please help if possible!

saurabhlatambale
join shbcf.ru