help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question that baffles AI (all of them)


From: Greg Wooledge
Subject: Re: Question that baffles AI (all of them)
Date: Sun, 16 Jun 2024 09:40:31 -0400

On Sat, Jun 15, 2024 at 09:51:49PM -0400, Saint Michael wrote:
> dat.sh 1 2 "the is a really long text that has ! commas,, and #3 , a, b" 4 5
> 1
> 2
> the, is, a, really, long, text, that, has, !, commas, , and, #3, a, b
> 4
> 5
> So there does not seem an obvious way to do this.
> Any ideas about how to send an arbitrary string to a bash script and
> get into a variable, without alterations?

The positional parameters (arguments, $1 and so on) are already available
without any modifications.  You just have to use them.

If you want to iterate over the entire list, you can use "$@" with
the double-quotes (that's critically important), or you can allow
the "for" command to do that implicitly.  It's the default behavior.


hobbit:~$ cat foo
#!/bin/bash
for arg; do
  printf '<%s>\n' "$arg"
done
hobbit:~$ ./foo 1 2 "the is a really long text that has ! commas,, and #3 , a, 
b" 4 5
<1>
<2>
<the is a really long text that has ! commas,, and #3 , a, b>
<4>
<5>


Note that I simply used <for arg>.  I could have written <for arg in "$@">
instead; it would have meant the same thing.

I do not see what this has to do with your CSV parsing question, though.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]