Does the shell associated index subscript have a limit on strings?

Source: Internet
Author: User

#!/bin/sh
if [[$#! = 1]];
Then
echo $ basepath;
echo;
Fi

path=$1;

Declare-a Statearray;

(Find $path-type f-print) | while read line;
Do
#echo "----"
echo $line;
#echo "----"
ftype= ' File-b "$line";
Ftype= ' echo ' $ftype | Cut-f 1-d "";
echo "$ftype";

Let statearray["$ftype"]++;

Done;

For type in "${!statearray[@]}";
Do
echo $type: ${statearray["$type"]};
Done


First, the function of the script:

Number of file types in the statistics directory

Problems occurred

ISO-8859 file types cannot be counted

Appear

Statearray:bad Array Subscript Error


To look at some documents, but did not find that the shell array in the correlation array subscript has strict restrictions, generally speaking is a string;

Test

Found

array["ISO-8859"]=1

bash:array["ISO-8859"]: Bad array subscript

But "ISO-8859" is also a string


So I still have some doubts! Ask Daniel again tomorrow.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.