Simple ksh knowledge

1. Parameter handover.

     The ksh paramerter comprises $order, for example, $0, $1. The $0 means the program itself or the function itself, just like the C++, so the $1 is the first parameter, $2 second...

     There are other parameter information,

       $# ----传递给程序的总的参数数目
     $? ----上一个代码或者shell程序在shell中退出的情况,如果正常退出则返回0,反之为非0值。
     $* ----传递给程序的所有参数组成的字符串。
       $n ----表示第几个参数,$1 表示第一个参数,$2 表示第二个参数 ... 
       $0 ----当前程序的名称
       $@----以"参数1" "参数2" ... 形式保存所有参数
       $$ ----本程序的(进程ID号)PID
       $!  ----上一个命令的PID

2. How to obtain the program option paramters.

#!/bin/bash
#getopts
ALL=false
HELP=false
FILE=false
VERBOSE=false
while getopts ahfvc: OPTION   #将ahfvc依次传给OPTION c后面的:表示-c时需传入参数
do
  case ${OPTION} in
    a)
      ALL=true
      echo "ALL IS ${ALL}"
      ;
    h)
      HELP=true
      echo "HELP IS ${HELP}"
      ;
    f)
      FILE=true
      echo "FILE IS ${FILE}"
      ;
    v)
      VERBOS=false
      echo "VERBOSE IS ${VERBOSE}"
      ;
    c)
      c=${OPTARG}
      echo "value is $c"
      ;
    /?)
      echo "`basename $0` -[a h f v] -[c value] file"
      ;
    esac
done


输入./getopts -a   输出:ALL IS true   #执行case a模式的命令
输入./getopts -h   输出:HLEP IS true #执行case h模式的命令
输入./getopts -f   输出:FILE IS true   #执行case f模式的命令
输入./getopts -v   输出:VERBOSE IS true   #执行case v模式的命令
输入./getopts -c   提示错误:需要传入参数 #c后面有“:”所以需传参数
输入./getopts -c hello 输出:c value is hello     #执行case c模式的命令
输入./getopts -b   输出:basename ./getopts -[a h f v] -[c value] file   #其他情况
  

3. How to compare 2 string?

            The sign = is used to compare the 2 stirngs while -eq is used to compare the 2 numbers.

比较两个字符串是否相等的办法是:

if [ "$test"x = "test"x ]; then

这里的关键有几点:

1) 使用单个等号

2) 注意到等号两边各有一个空格:这是unix shell的要求

3) 注意到"$test"x最后的x,这是特意安排的,因为当$test为空的时候,上面的表达式就变成了x = testx,显然是不相等的。而如果没有这个x,表达式就会报错:[: =: unary operator expected

4) There is bank right behind [ and before ], they are necessary.

 

4. Simple commands.

       stty erase <BackSpace> ###use the backslash as the delete key.

       PS1="`/usr/ucb/whoami`@`uname -n`(KSH)[!]> " ###used to cumtomiz the command echo.

       set -o vi ###set the edition mode as vi, you have the command history with that.

      find . -name "test" -type f ! -newer source_test -exec cp source_test {} /; ###How to copy file when the destination file is newer file?

 

How to use the options parameters.  

http://blog.chinaunix.net/u/5591/showart_371375.html

 

Please refer to the tutorial.

http://www.xxlinux.com/linux/article/unix/tigao/2006-06-24/1958.html

http://www.xxlinux.com/linux/article/unix/tigao/2006-06-24/1959.html

http://www.xxlinux.com/linux/article/unix/tigao/2006-06-24/1960.html

 

Ksh reference manual.

http://docs.sun.com/app/docs/doc/819-2239/ksh-1?l=en&a=view&q=ksh

世界地图矢量数据可以通过多种网站进行下载。以下是一些提供免费下载世界地图矢量数据的网站: 1. Open Street Map (https://www.openstreetmap.org/): 这个网站可以根据输入的经纬度或手动选定范围来导出目标区域的矢量图。导出的数据格式为osm格式,但只支持矩形范围的地图下载。 2. Geofabrik (http://download.geofabrik.de/): Geofabrik提供按洲际和国家快速下载全国范围的地图数据数据格式支持shape文件格式,包含多个独立图层,如道路、建筑、水域、交通、土地利用分类、自然景观等。数据每天更新一次。 3. bbbike (https://download.bbbike.org/osm/): bbbike提供全球主要的200多个城市的地图数据下载,也可以按照bbox进行下载。该网站还提供全球数据数据格式种类齐全,包括geojson、shp等。 4. GADM (https://gadm.org/index.html): GADM提供按国家或全球下载地图数据的服务。该网站提供多种格式的数据下载。 5. L7 AntV (https://l7.antv.antgroup.com/custom/tools/worldmap): L7 AntV是一个提供标准世界地图矢量数据免费下载的网站。支持多种数据格式下载,包括GeoJSON、KML、JSON、TopJSON、CSV和高清SVG格式等。可以下载中国省、市、县的矢量边界和世界各个国家的矢量边界数据。 以上这些网站都提供了世界地图矢量数据免费下载服务,你可以根据自己的需求选择合适的网站进行下载
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值