Instead, provide the delimiter string on the command line in such a way that it will be properly interpreted within the script. For example, in bash (or other unix/bourne-like shell), you could do:
(or whatever the command line is supposed to look like) -- note that quotation marks are placed around the delimiter string, so that the backslash and vertical bar are passed to the script without being interpreted by the shell. If your script does not use quotemeta, then the regex for the split will be:your_script -d '\|' foo bar
which is exactly what you want. Now, suppose you really want to use some "magic" regex characters for your delimiter string... e.g. your input file has lines like this:/\|/
and you need to split on colon, semi-colon and space. The command-line option for the delimiter would then be:foo:bar;baz;blork blix etc foo2:bar3;bazx;blrk blx and-so-on
If you used quotemeta on the delimiter string inside your script, this sort of flexibility would not be possible.your_script -d '[:; ]' that.file
In reply to Re: problem with split function
by graff
in thread problem with split function
by jclaudio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |