gembin

          OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

          HBase, Hadoop, ZooKeeper, Cassandra

          Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

          There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

          About Me

           

          Get substring of a string under UNIX/Linux

          there many ways to do so.


          str="hello world"

          1) cut
          Where -cN-M tells the cut command to return columns N to M, inclusive. 
          cut -cN-M

          start=1
          end=5
          sub_str=`echo ${str} | cut -c${start}-${end}`
          output: hello

          2) bash 
          Note: if you are not sure of having bash, consider using cut. 
          ${str:offset}
          $
          {str:offset:length}

          sub_str=${str:0:5}
          output: hello

          3) expr

          expr substr string position length 
          sub_str=`expr substr $str 1 5`
          output: hello

           

          posted on 2012-04-01 15:38 gembin 閱讀(835) 評論(0)  編輯  收藏 所屬分類: Linux

          導航

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(440)

          隨筆檔案(378)

          文章檔案(6)

          新聞檔案(1)

          相冊

          收藏夾(9)

          Adobe

          Android

          AS3

          Blog-Links

          Build

          Design Pattern

          Eclipse

          Favorite Links

          Flickr

          Game Dev

          HBase

          Identity Management

          IT resources

          JEE

          Language

          OpenID

          OSGi

          SOA

          Version Control

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          free counters
          主站蜘蛛池模板: 灵璧县| 孟州市| 黑河市| 隆尧县| 保山市| 内江市| 玉门市| 湖州市| 布拖县| 屯门区| 临猗县| 常熟市| 尉氏县| 邵东县| 龙里县| 威信县| 汉寿县| 越西县| 通城县| 孟州市| 海林市| 三河市| 拜泉县| 鄂温| 永州市| 宣城市| 栖霞市| 化隆| 灵山县| 沁源县| 三亚市| 北辰区| 浏阳市| 酉阳| 济南市| 德阳市| 普兰县| 如东县| 巨野县| 东源县| 宜昌市|