help-bash
[Top][All Lists]
Advanced

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

[Help-bash] Taking a slice of an array


From: Bill Gradwohl
Subject: [Help-bash] Taking a slice of an array
Date: Sun, 8 Apr 2012 20:59:46 -0600

#!/bin/bash
array=(a b c d e f g)
echo "${array[1]} ${#array[1]}"
string="address@hidden:1:4}"
echo "${string} ${#string}"


Produces:

address@hidden ycc# ./ascii
b 1
b c d e 7

I was expecting 'bcde' with a length of 4 after reading man bash.
Why the spaces?
I thought that possibly it was some IFS related issue so I set IFS='' on a separate statement but that changed nothing.

Thank You

--
Bill Gradwohl


reply via email to

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