当前位置: 首页 > news >正文

网站开发demo杭州seo薪资水平

网站开发demo,杭州seo薪资水平,龙湾区住房与城乡建设局网站,青海城乡住房和建设厅网站linux文件间最佳传参方式$0 $1方式parse_options.sh传参方式--a 30 --b 40parse_options.sh内容$0 $1方式 $0代表传进文件中的具体文件名,$1开始是参数,但是这种方式不支持文件里面给定默认值 不是很喜欢这种文件间传参方式 parse_options.sh传参方式–…

linux文件间最佳传参方式

  • $0 $1方式
  • parse_options.sh传参方式--a 30 --b 40
  • parse_options.sh内容

$0 $1方式

$0代表传进文件中的具体文件名,$1开始是参数,但是这种方式不支持文件里面给定默认值
不是很喜欢这种文件间传参方式

parse_options.sh传参方式–a 30 --b 40

一直在研究kaldi,kaldi里面的很多东西都很受用,里面有一个脚本叫parse_options.sh,可以直接更新和获取传进文件的参数。好处是:

  • 在执行. ./parse_options.sh之前,申请变量,给定默认值
  • 在执行. ./parse_options.sh之后,可以获取传进该文件中的--a 30 --b 40这样的键值对,然后直接更新新值
    具体使用方式如下:
# 调用demo.sh文件的方式和结果
sh demo.sh --a 30 --b 40
# $0 =demo.sh $1=--a $2=30
# 默认值:a=3 b=4
# 更新值:a=30 b=40
# demo.sh文件中内容
a=3
b=4
echo "\$0 =${0} \$1=${1} \$2=${2}"
echo "默认值:a=${a} b=$b"
# 用该命令更新值
. ./parse_options.sh
echo "更新值:a=${a} b=$b"

parse_options.sh内容

原始的parse_options.sh直接使用存在bug,需要将parse_options.sh#L66第66行给注释掉,就可以使用,如果想使用,请直接下载提供demo的资源地址.

#parse_option.sh 内容
#!/bin/bash# Copyright 2012  Johns Hopkins University (Author: Daniel Povey);
#                 Arnab Ghoshal, Karel Vesely# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
# WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
# MERCHANTABLITY OR NON-INFRINGEMENT.
# See the Apache 2 License for the specific language governing permissions and
# limitations under the License.# Parse command-line options.
# To be sourced by another script (as in ". parse_options.sh").
# Option format is: --option-name arg
# and shell variable "option_name" gets set to value "arg."
# The exception is --help, which takes no arguments, but prints the
# $help_message variable (if defined).###
### The --config file options have lower priority to command line
### options, so we need to import them first...
#### Now import all the configs specified by command-line, in left-to-right order
for ((argpos=1; argpos<$#; argpos++)); doif [ "${!argpos}" == "--config" ]; thenargpos_plus1=$((argpos+1))config=${!argpos_plus1}[ ! -r $config ] && echo "$0: missing config '$config'" && exit 1. $config  # source the config file.fi
done###
### Now we process the command line options
###
while true; do[ -z "${1:-}" ] && break;  # break if there are no argumentscase "$1" in# If the enclosing script is called with --help option, print the help# message and exit.  Scripts should put help messages in $help_message--help|-h) if [ -z "$help_message" ]; then echo "No help found." 1>&2;else printf "$help_message\n" 1>&2 ; fi;exit 0 ;;--*=*) echo "$0: options to scripts must be of the form --name value, got '$1'"exit 1 ;;# If the first command-line argument begins with "--" (e.g. --foo-bar),# then work out the variable name as $name, which will equal "foo_bar".--*) name=`echo "$1" | sed s/^--// | sed s/-/_/g`;# Next we test whether the variable in question is undefned-- if so it's# an invalid option and we die.  Note: $0 evaluates to the name of the# enclosing script.# The test [ -z ${foo_bar+xxx} ] will return true if the variable foo_bar# is undefined.  We then have to wrap this test inside "eval" because# foo_bar is itself inside a variable ($name).# eval '[ -z "${'$name'+xxx}" ]' && echo "$0: invalid option $1" 1>&2 && exit 1;oldval="`eval echo \\$$name`";# Work out whether we seem to be expecting a Boolean argument.if [ "$oldval" == "true" ] || [ "$oldval" == "false" ]; thenwas_bool=true;elsewas_bool=false;fi# Set the variable to the right value-- the escaped quotes make it work if# the option had spaces, like --cmd "queue.pl -sync y"eval $name=\"$2\";# Check that Boolean-valued arguments are really Boolean.if $was_bool && [[ "$2" != "true" && "$2" != "false" ]]; thenecho "$0: expected \"true\" or \"false\": $1 $2" 1>&2exit 1;fishift 2;;;*) break;esac
done# Check for an empty argument to the --cmd option, which can easily occur as a
# result of scripting errors.
[ ! -z "${cmd+xxx}" ] && [ -z "$cmd" ] && echo "$0: empty argument to --cmd option" 1>&2 && exit 1;true; # so this script returns exit code 0.
http://www.lbrq.cn/news/2346391.html

相关文章:

  • 做淘宝门头的网站查排名的网站
  • vps运行iis网站 需要输入账号和密码网上培训课程平台
  • 免费做的英文网站今日新闻播报
  • 企业动态网站产品市场营销策划书
  • 网站设置访问密码太原seo网站管理
  • 如何才能建设出一个优秀网站b2b网站平台有哪些
  • 互动的网站青岛官网优化
  • wordpress 打车公司网站优化
  • 昆山做网站的公司如何推广网站运营
  • 找人做网站要准备什么软件百度热搜大数据
  • 怎样才能做公司的网站媒介星软文平台
  • 做理财的网站有哪些如何免费建立一个网站
  • 网站建设辅助云南网络推广seo代理公司
  • 专业网页网站设计图书东莞网站制作十年乐云seo
  • 做视频网站服务器配置有了域名如何建立网站
  • 广西建设厅微信网站海南百度推广运营中心
  • wordpress链接尾缀网站搜索引擎优化主要方法
  • 网页设计素材网站有哪些seo网站优化方法
  • 深圳有哪些大公司优化大师兑换码
  • 没有备案的交易网站企业网站推广的形式有哪些
  • 怎么做网站地图的样式营销网站建设的因素
  • 注册网站合集网站建设平台软件
  • 京东商城商务网站建设目的个人开发app去哪里接广告
  • 怎么做网站的内部链接seo评测论坛
  • 去除wordpress活动及新闻seo的优化步骤
  • php自己写框架做网站seo网站关键词排名快速
  • 西安网站建设设计b2b平台运营模式
  • iis怎么使用来建设一个网站重庆网站seo服务
  • 深圳市律师网站建设怎么样自己做网站设计制作
  • 网站建设方案书的内容管理制度百度移动seo首选帝搜软件
  • 【安卓笔记】RxJava之flatMap的使用
  • HR数字化转型:3大痛点解决方案与效率突破指南
  • AutoGPT vs BabyAGI:自主任务执行框架对比与选型深度分析
  • 网络编程(套接字)
  • Linux 系统下的 Sangfor VDI 客户端安装与登录完全攻略 (CentOS、Ubuntu、麒麟全线通用)
  • 不用下载软件也能录屏?Windows 10 自带录屏功能详解