Ruby case statement to Bash
How can t开发者_如何学编程his be translated to bash:
case ARGV[1]
when 'English', 'en'
dump_filename = "dump_english.sql"
when 'French', 'fr'
dump_filename = "dump_french.sql"
else
dump_filename = "dump.sql"
end
Thanks.
Use the bash case
statement:
#!/bin/bash
arg=$1
case "$arg" in
English) file="dump_english.sql" ;;
en) file="dump_english.sql" ;;
French) file="dump_french.sql" ;;
fr) file="dump_french.sql" ;;
*) file="dump.sql" ;;
esac
echo "$file"
精彩评论