Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
In bash (which is still widely used despite all its limitations as it's the GNU shell so pre-installed on virtually all GNU/Linux systems as well as a few non-GNU systems), you can do it in two steps:
In bash, you can do it in two steps:
In bash (which is still widely used despite all its limitations as it's the GNU shell so pre-installed on virtually all GNU/Linux systems as well as a few non-GNU systems), you can do it in two steps:
(- 1 because read starts filling up the array andat index 0, not 1; LC_ALL=C works around some bugssome bugs for text not encoded in the user's encoding in bash versions 5.0 to 5.2)
(- 1 because read starts filling up the array and index 0, not 1; LC_ALL=C works around some bugs for text not encoded in the user's encoding in bash versions 5.0 to 5.2)
(- 1 because read starts filling up the array at index 0, not 1; LC_ALL=C works around some bugs for text not encoded in the user's encoding in bash versions 5.0 to 5.2)