?? ex7.sh
字號(hào):
#!/bin/bashvar1=abcd-1234-defgecho "var1 = $var1"t=${var1#*-*}echo "var1 (with everything, up to and including first - stripped out) = $t"# t=${var1#*-} works just the same,#+ since # matches the shortest string,#+ and * matches everything preceding, including an empty string.# (Thanks, Stephane Chazelas, for pointing this out.)t=${var1##*-*}echo "If var1 contains a \"-\", returns empty string... var1 = $t"t=${var1%*-*}echo "var1 (with everything from the last - on stripped out) = $t"echo# -------------------------------------------path_name=/home/bozo/ideas/thoughts.for.today# -------------------------------------------echo "path_name = $path_name"t=${path_name##/*/}echo "path_name, stripped of prefixes = $t"# Same effect as t=`basename $path_name` in this particular case.# t=${path_name%/}; t=${t##*/} is a more general solution,#+ but still fails sometimes.# If $path_name ends with a newline, then `basename $path_name` will not work,#+ but the above expression will.# (Thanks, S.C.)t=${path_name%/*.*}# Same effect as t=`dirname $path_name`echo "path_name, stripped of suffixes = $t"# These will fail in some cases, such as "../", "/foo////", # "foo/", "/".# Removing suffixes, especially when the basename has no suffix,#+ but the dirname does, also complicates matters.# (Thanks, S.C.)echot=${path_name:11}echo "$path_name, with first 11 chars stripped off = $t"t=${path_name:11:5}echo "$path_name, with first 11 chars stripped off, length 5 = $t"echot=${path_name/bozo/clown}echo "$path_name with \"bozo\" replaced by \"clown\" = $t"t=${path_name/today/}echo "$path_name with \"today\" deleted = $t"t=${path_name//o/O}echo "$path_name with all o's capitalized = $t"t=${path_name//o/}echo "$path_name with all o's deleted = $t"exit 0
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -