zoukankan      html  css  js  c++  java
  • shell map

    #!/bin/bash
    
    # Only 1 parameter !
    if [ $# != 2 ];then
            echo " Usage: .
    ead.sh filename parameter !";
        exit
    fi
    
    # check the file !
    if ! [ -f $1 ];then
        echo "file does not exist!"
        exit
    elif ! [ -r $1 ];then
        echo "file can not be read !"
        exit
    fi
    
    # PRESS ANY KEY TO CONTITUE !
    read -p "begin to read $1 "
    
    # set IFS="
    " , read $1 file per line !
    IFS="
    "
    
    # i is the line number
    i=1
    for line in `cat $1`
    do
        echo line $i:$line
        let "i=$i+1"
    done
    
    declare -A myMap
    
    IFS=" "
    while read key val
    do
        echo 键=$key 值=$val
        myMap[$key]=$val
    done <  $1
    echo ${myMap[$2"_user"]}
    echo ${!myMap[@]}
    echo "Finished reading file by line ! "
    

      

  • 相关阅读:
    CF258D
    CF662C
    CF1295F
    CF1406E
    CF1270F
    CF1278F
    CF1523E
    CF1554E
    算法第四章上机实践报告
    LCA RMQ+ST表学习笔记
  • 原文地址:https://www.cnblogs.com/Babylon/p/14609778.html
Copyright © 2011-2022 走看看