`

shell split string

阅读更多
Method 1
#!/bin/sh
# for usb auto suspend , triggered by usb insert
stringK=$1
i=1
seg="1-1"
while [ -n "$seg" ]
do
  if [ "$i" -eq "1" ]; then
    stringU=$seg
  else
    stringU=$stringU"."$seg
  fi
  if [ -d /sys/bus/usb/devices/$stringU ]; then
....
  fi
  let "i+=1"
  seg=`echo $stringK $i|                               
  awk '{ split($1,list,"."); print list[$2] }'`
done
exit 0


Method 2
#!/bin/bash
A=1-1.2.4:1.0
IFS=:
B=($A)
echo $B
while [ "$B" != "${B%.*}" ] ; do
   B=${B%.*}
   echo $B
done

分享到:
评论

相关推荐

    Linux里awk中split函数的用法小结

    The awk function split(s,a,sep) splits a string s into an awk array a using the delimiter sep

    cl-shellwords:通用Lisp库,用于转义外壳程序的字符串,或根据外壳程序规则拆分字符串

    分裂(split string) 将STRING分成单词列表,以类似于Bourne shell的shell方式进行转义。 空格通常用作单词分隔符,除非在前面加上反斜杠或将其括在单引号或双引号中。 Examples:(split " example string " ); => (...

    Awk入门教程 《Awk A Tutorial and Introduction - by Bruce Barnett》

    Which shell to use with AWK? Dynamic Variables The Essential Syntax of AWK Arithmetic Expressions Unary arithmetic operators The Autoincrement and Autodecrement Operators Assignment Operators ...

    java sql注入l

    59 String[] badStrs = badStr.split("\\|"); 60 for (int i = 0; i ; i++) { 61 if (str.indexOf(badStrs[i]) >= 0) { 62 return true; 63 } 64 } 65 return false; 66 } 67 } 68 69 70 <...

    VB自动关机源码.rar

    Dim temp() As String = shutTime.Split(";") 'temp字符串数组存放shutTime以";"分隔的各个字符子串 Dim t As String 't存放temp字符串数组的一项 ListBox1.Items.Clear() For Each t In temp If Not (Mid(t, 1...

    使用Python构造hive insert语句说明

    mysql可以使用nevicat导出insert...def transformString(s): list_s = s.split('\t') print(len(list_s)) s_new = '' for item in list_s: s_new += '\"' + item.strip(' ') + '\"' + ',' return str(s_new.rstrip(','

    2009 达内Unix学习笔记

    各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ 一、注意事项 命令和参数之间必需用空格隔开,参数和参数之间也必需用空格隔开。 一行不能超过256个字符;大小写有区分。 二、特殊字符...

    GNULinuxApplicationProgramming

    This book is split into five parts, each focusing on different aspects of GNU/Linux programming. Part I, “Introduction,” introduces GNU/Linux for the beginner. It addresses the GNU/Linux ...

    i-vector的工具箱

    String arguments, either for a file name or a numerical value, are useful when these tools are compiled and called from a shell command line. This makes it easy to use the tools on machines with ...

    Tcl_TK编程权威指南pdf

    string命令 append命令 format命令 scan命令 binary命令 相关章节 第5章 tcl列表 tcl列表 构建列表 获取列表元素 修改列表 搜索列表 对列表进行排序 split命令 join命令 相关章节 第6章 控制结构...

    RED HAT LINUX 6大全

    14.9.13 comment=(S)和server string= (G) 257 14.9.14 domain logons=(G) 257 14.9.15 encrypt passwords=和smb passwd file=(G) 257 14.9.16 hosts equiv=(G) 257 14.9.17 interfaces=(G) 257 14.9.18 load ...

    UG6.0快捷键大全

    SYNONYMS edit string, edit section, edit profile, open sketch HELP DSN_feature_edit BITMAP sketch.bmp POPUP_LABEL Edit S&ketch... POPUP_MESSAGE Opens the Sketch task environment to edit the ...

    UE(官方下载)

    The lists lines option can be a handy tool when searching because it presents all occurrences of the find string in a floating dialog box. You can use the dialog to navigate to each instance by double...

    2017最新大数据架构师精英课程

    14_String-StringBuffer-StringBuilder 15_集合-list-arrayList-linkedlist 16_集合-hashset-hashmap-迭代器-entryset$ d3 b$ ~5 b! @- Z* }- C 17_快捷键设置* L* C. y4 Z1 v0 p) [8 p3 A 18_IO& f, H- i' w( B; P%...

    lunch_cb5801_r58_20160907.7z

    ./recovery/Android.mk:ifneq (,$(findstring $(TARGET_DEVICE),octopus-perf)) ./recovery/Android.mk:LOCAL_MODULE := librecovery_ui_octopus_perf ./recovery/Android.mk:LOCAL_MODULE := librecovery_updater_...

    lunch_r58_20160906.7z

    ./recovery/Android.mk:ifneq (,$(findstring $(TARGET_DEVICE),octopus-perf)) ./recovery/Android.mk:LOCAL_MODULE := librecovery_ui_octopus_perf ./recovery/Android.mk:LOCAL_MODULE := librecovery_updater_...

    js使用小技巧

    Javascript小技巧一箩筐 事件源对象 event.srcElement.tagName event.srcElement.type ... 捕获释放 event.srcElement.setCapture();...event.srcElement.releaseCapture();... 根据鼠标获得元素: document....

    VB编程资源大全(英文源码 其它)

    You can also set the length of the returned string. Great of coming up with random passwords for your applications.<END><br>42,norepeat.zip A simple program that generates non repeating numbers ...

    在b/s开发中经常用到的javaScript技术整理

    在b/s开发中经常用到的javaScript技术整理 一、验证类 1、数字验证内 1.1 整数 1.2 大于0的整数 (用于传来的ID的验证) ... 4.3 判断字符由字母和数字,下划线,点号组成.... 4.3 判断字符由字母和数字,下划线,...

Global site tag (gtag.js) - Google Analytics