sry i have a stupid question.
I have a variable and need to know how many items are in it.
for example:
variable="abc xyz foo"
what program can i call to print out 3
right now im doing this...
Counter()
{
echo $#
}
Counter $IDs
but that just seems stupid
--
View this message in contex
> ...but then I have to shell quote the file name myself to handle
> spaces, brackets of various sorts, comma characters etc. Will hunt for
> such a function and see. There are all sorts of crazy helper functions
> in /etc/bash_completion, of which I barely understand anything.
I did not find any
> Hm, compgen appears to behave strange if words contain whitespace.
> However, you don't need it, as you build the list yourself. Try this:
>
> _mm2() {
> local cur files
> cur=${COMP_WORDS[COMP_CWORD]}
> files=$(find /home/mathias/Videos/movies/ -iname "$cur*.avi" -type
> f -p
On Thu, 24 Sep 2009, David Martin wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
> -DCO
On Thursday 24 September 2009 16:38:12 David Martin wrote:
> Description:
> When populating an array from a string in a variable does not
> handle quotes.
>
> Repeat-By:
>
> ~$ declare -a samplearray
> ~$ samplearray=( x y 'z k')
> ~$ echo ${samplearray[2]}
> z k
> ~$ samplestring="x y 'z
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDI$
uname output: Linux bristol 2
Thank you for setting me straight! I had checked the POSIX spec
before sending the report but missed the part about the delimiter
having to be immediately followed by newline.
Martin
On 09/24/2009 06:39 AM, Chet Ramey wrote:
Machine Type: i386-redhat-linux-gnu
Bash Version: 4.0
Patch Level: 23
On Thu, 24 Sep 2009, Bernd Eggink wrote:
> Chet Ramey schrieb:
> > > Hm, compgen appears to behave strange if words contain whitespace.
> >
> > Well, it splits the argument to -W on $IFS as documented. What other
> > strange behavior do you see?
>
> For example, this:
>
> function _aha
>
given below will work except tab at beginning.
echo "Hello, how are you doing today?" | tr -s " " "\n"
Thanks,
Mahaveer
+91 9052000707
On Thu, Sep 24, 2009 at 12:33 AM, eatsubway wrote:
>
> hello, i have a simple question. I have a string which i would like to
> format by replacing spaces
Bernd Eggink wrote:
> Chet Ramey schrieb:
>>> Hm, compgen appears to behave strange if words contain whitespace.
>>
>> Well, it splits the argument to -W on $IFS as documented. What other
>> strange behavior do you see?
>
> For example, this:
>
> function _aha
> {
> local list=
Chet Ramey schrieb:
Hm, compgen appears to behave strange if words contain whitespace.
Well, it splits the argument to -W on $IFS as documented. What other
strange behavior do you see?
For example, this:
function _aha
{
local list="a b:c d:e f"
COMPREPLY=($(IFS=: co
> Thanks for the confirmation. Maybe CHANGES can be updated to list all
> the changes that were made as a consequence of the Austin Group's
> interpretation.
Here's the new description of "set -e":
-e When this option is on, when any command fails (for any of the
reasons listed in [xref
* Chet Ramey [2009-09-24 08:29]:
> > l. Changed behavior of shell when -e option is in effect to reflect
> > consensus
> > of Posix shell standardization working group.
>
> This behavior is one of the consequences of the Austin Group's interpretation.
> Failures of user-specified subshe
> Hm, compgen appears to behave strange if words contain whitespace.
Well, it splits the argument to -W on $IFS as documented. What other
strange behavior do you see?
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
> Machine Type: i386-redhat-linux-gnu
>
> Bash Version: 4.0
> Patch Level: 23
> Release Status: release
>
> Description:
> Bash 4.0 errors on a here-document enclosed in $(). For example:
> x=$(cat < foo
> bar
> EOF)
> Ctrl+D
> -bash: unexpected EOF while
> I noticed that bash has changed behaviour regarding subshell handling,
> breaking a script of mine. Now a script with -e fails when a subshell
> fails whereas it didn't before. I looked at the CHANGES file and
> couldn't find anything about this, so I wanted to ask if this change
> was intentio
Mathias Dahl schrieb:
It depends heavily on how the variables IFS and zf are set. From 'man bash':
-W wordlist
The wordlist is split using the characters in the IFS special
variable as delimiters, and each resultant word is expanded.
The possible completions are the members of the
17 matches
Mail list logo