[SOLVED] Bash command syntax, help, input filename with spaces No such file or directory
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The select statement in Bash is nice, but rather limited. Anyway, you're OK as long as it covers your needs. For more precise and sophisticated menu control I'd rather use something like smenu, pick, or write my own menu handling function. I hesitate to recommend iselect as it is less flexible than smenu and was not updated in ages. OTOH, depending on your needs it's also could still be useful.
Some random thoughts.
Quote:
Originally Posted by postcd
IFS=$(echo -e '\n')
It's not needed for mapfile, but I want to comment on this nevertheless. You're using select which is a Bash-specific feature anyway. Bash has the ANSI-C quoting ($'string'). IFS=$'\n' is the usual Bash incantation for this. But even if you prefer to stay POSIX-conform, the right way to assign newline to IFS would be
Code:
IFS=${IFS#??}
This works because according to POSIX, the default value of IFS is <space><tab><newline> in this exact order.
Judging by your troubles to get this right, I'd suggest you read up on how to parse file names.
Seriously, unless you want to spend the rest of your programming life escaping spaces / quoting vars, which is tedious to type and painful to read, start by renaming the files .
Classically, substitute underscores for the spaces. After that, things will be much easier.
Also, use multiple lines for your code; don't try to jam it all on one line.
Again, it's hard to read and even harder to debug.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.