Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/bash
  2. if [ "$action" == "set" ]
  3. then
  4.     key=$2
  5.     value=$3
  6.     touch map.csv
  7.     echo -e "$key,$value">>map.csv
  8. else
  9.     targetKey=$1
  10.     declare -A map
  11.     while read line
  12.     do
  13.     IFS=',' read -a array <<<"$line"
  14.     count=0
  15.     for element in "${array[@]}"
  16.     do
  17.         rem=$(( $count % 2 ))
  18.         if [ $rem -eq 0 ]
  19.         then
  20.         key=$element
  21.         else
  22.         value=$element
  23.         map[$key]=$value
  24.         fi
  25.         count=$count+1
  26.     done
  27.     done < map.csv
  28.     cd ${map[$targetKey]}
  29.     exec bash
  30. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement