[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question that baffles AI (all of them)
From: |
alex xmb sw ratchev |
Subject: |
Re: Question that baffles AI (all of them) |
Date: |
Sun, 16 Jun 2024 19:00:10 +0200 |
ur for arg printf arg in one cmd ..
printf '<%s>\n' "$@"
On Sun, Jun 16, 2024, 3:41 PM Greg Wooledge <greg@wooledge.org> wrote:
> 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.
>
>