ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
will delimit each part of which resides between two simple , and/or simple ; instead of ,; as a delimiter
How is emulated/workaround way, so that gives a solution? Thanks before
Bash doesn't have any options to support multi-character IFS.
Either replace it with a character guaranteed not to appear, and use that character for IFS (as per NevemTeve's post), or use a tool which does support multi-character separators, like Awk.
Depending on what you need to do, either FS or RS may be more appropriate...
Is there any way or workaround resorts to correctly have separator IFS on a condition that
it's a certain character only if not preceded by another certain character ?
Let e.g. separator must be `;` not being preceded by `\`
or e.g. separator must be `|` not being preceded by `\`
So obviously you didn't like any of the answers provided here,
however the answer is still the same that IFS uses a single character at all times. You can assign multiple but it will stop once it finds a matching character in its list.
As above, you need to pick a language that has native regex. Bash does have a regex part to it but then you would be looking to do the line separating using your own function.
additionally you may download the source of bash and implement this feature.
but need to take care about the original behavior too: https://bash.cyberciti.biz/guide/$IFS
Please post your question only once to allow participants to more easily follow the development of the discussion and prevent duplication of effort. Asking about two character IFS, or IFS with one character that follows another looks like the same question so your two threads have been merged into one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.