亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
12下一頁
最近訪問板塊 發(fā)新帖
查看: 3312 | 回復: 12
打印 上一主題 下一主題

[其他] bash ${^^} [復制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2013-02-01 16:37 |只看該作者 |倒序瀏覽
本帖最后由 hbmhalley 于 2013-02-01 16:40 編輯

  1. $ b=abcd

  2. $ echo ${b^a} # O
  3. Abcd

  4. $ echo ${b^ab} # X
  5. abcd

  6. $ echo ${b^d} # X
  7. abcd

  8. $ echo ${b^^d} # O
  9. abcD

  10. $ echo ${b^^cd} # X
  11. abcd

  12. $ echo ${b%d} # O
  13. abc

  14. $ bash --version
  15. GNU bash, version 4.1.10(4)-release (i686-pc-cygwin)
復制代碼
為什么三個標 X 的沒有成功替換成大寫?

論壇徽章:
93
2015年辭舊歲徽章
日期:2019-10-10 10:51:15CU大;照
日期:2014-02-21 14:21:56CU十二周年紀念徽章
日期:2020-10-15 16:55:55CU大;照
日期:2014-02-21 14:22:07羊年新春福章
日期:2019-10-10 10:51:39CU大;照
日期:2019-10-10 10:55:38季節(jié)之章:春
日期:2020-10-15 16:57:40ChinaUnix元老
日期:2019-10-10 10:54:42季節(jié)之章:冬
日期:2019-10-10 10:57:17CU大;照
日期:2014-02-21 14:22:52CU大;照
日期:2014-03-13 10:40:30CU大;照
日期:2014-02-21 14:23:15
2 [報告]
發(fā)表于 2013-02-01 16:59 |只看該作者
這么高級的功能沒用過呢,看來我是沒機會用了……
  1. [seesea@UC ~]$ b=abcd
  2. [seesea@UC ~]$ echo ${b^a}
  3. -bash: ${b^a}: bad substitution
  4. [seesea@UC ~]$ echo ${b^^a}
  5. -bash: ${b^^a}: bad substitution
  6. [seesea@UC ~]$ bash --version
  7. GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
  8. Copyright (C) 2005 Free Software Foundation, Inc.

復制代碼
  1. seesea@UC ~/桌面
  2. $ b=abcde

  3. seesea@UC ~/桌面
  4. $ echo ${b^a}
  5. bash: ${b^a}: bad substitution

  6. seesea@UC ~/桌面
  7. $ bash --version
  8. GNU bash, version 2.05b.0(1)-release (i686-pc-cygwin)
  9. Copyright (C) 2002 Free Software Foundation, Inc.
復制代碼

論壇徽章:
0
3 [報告]
發(fā)表于 2013-02-01 17:19 |只看該作者
  1. 站個樓 下個bash 4看看去
復制代碼

論壇徽章:
5
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亞洲杯之朝鮮
日期:2015-03-13 22:47:33IT運維版塊每日發(fā)帖之星
日期:2016-01-09 06:20:00IT運維版塊每周發(fā)帖之星
日期:2016-03-07 16:27:44
4 [報告]
發(fā)表于 2013-02-01 17:48 |只看該作者
bash 4 新功能吧,還沒用過。

論壇徽章:
0
5 [報告]
發(fā)表于 2013-02-01 20:43 |只看該作者
@seesea2517
@V_客
@blackold

大家平時都在什么環(huán)境下?如果有包管理工具的話應該不會長時間不更新吧

論壇徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年紀念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役紀念章
日期:2022-04-24 14:33:24
6 [報告]
發(fā)表于 2013-02-01 20:46 |只看該作者
       ${parameter^pattern}
       ${parameter^^pattern}
       ${parameter,pattern}
       ${parameter,,pattern}
              Case modification.  This expansion modifies the case of alphabetic characters in parameter.  The pattern is expanded to produce  a  pattern  just  as  in  pathname
              expansion
.   The  ^ operator converts lowercase letters matching pattern to uppercase; the , operator converts matching uppercase letters to lowercase.  The ^^ and
              ,, expansions convert each matched character in the expanded value; the ^ and , expansions match and convert only the first character in the expanded  value..   If
              pattern  is  omitted, it is treated like a ?, which matches every character.  If parameter is @ or *, the case modification operation is applied to each positional
              parameter in turn, and the expansion is the resultant list.  If parameter is an array variable subscripted with @ or *, the case modification operation is  applied
              to each member of the array in turn, and the expansion is the resultant list.

首先要搞清楚什么是pathname expansion,這一點很關(guān)鍵。
其次要分清^和^^,前者是first,后者是each
你先仔細想想,實在不明白再問。

論壇徽章:
5
2015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亞洲杯之朝鮮
日期:2015-03-13 22:47:33IT運維版塊每日發(fā)帖之星
日期:2016-01-09 06:20:00IT運維版塊每周發(fā)帖之星
日期:2016-03-07 16:27:44
7 [報告]
發(fā)表于 2013-02-01 20:56 |只看該作者
回復 5# hbmhalley


    我只是玩,工作很少用到。
   
    之前還及時更新,后來覺得沒有必要,就改為必要時才更新——不更新不行了,或者有問題了。

論壇徽章:
0
8 [報告]
發(fā)表于 2013-02-01 21:01 |只看該作者
回復 6# Shell_HAT


    其實我還真不是太清楚,一直當成弱版正則
    但:
       ${parameter%word}
       ${parameter%%word}
              Remove matching suffix pattern.  The word is expanded to produce  a  pattern
              just as in pathname expansion.  If the pattern matches a trailing portion of
              the expanded value of parameter, then the result of  the  expansion  is  the
              expanded  value  of  parameter with the shortest matching pattern (the ``%''
              case) or the longest matching pattern (the ``%%'' case) deleted.  If parame‐
              ter  is  @ or *, the pattern removal operation is applied to each positional
              parameter in turn, and the expansion is the resultant list.  If parameter is
              an  array variable subscripted with @ or *, the pattern removal operation is
              applied to each member of the array in turn, and the expansion is the resul‐
              tant list.

    這也是上面把 ${%}作為參照的原因
    而且 ${b^^abcd} 同樣不成功

論壇徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年紀念徽章
日期:2019-08-20 08:30:3720周年集字徽章-周	
日期:2020-10-28 14:13:3020周年集字徽章-20	
日期:2020-10-28 14:04:3019周年集字徽章-CU
日期:2019-09-08 23:26:2519周年集字徽章-19
日期:2019-08-27 13:31:262016科比退役紀念章
日期:2022-04-24 14:33:24
9 [報告]
發(fā)表于 2013-02-01 21:29 |只看該作者
回復 8# hbmhalley


    大小寫轉(zhuǎn)換時的pattern只能是一個character,不像子串刪除或者替換的時候pattern可以是一個string

論壇徽章:
0
10 [報告]
發(fā)表于 2013-02-01 21:49 |只看該作者
本帖最后由 hbmhalley 于 2013-02-01 21:50 編輯

回復 9# Shell_HAT


    這樣啊!
    但為什么手冊里沒發(fā)現(xiàn) .. 難道我E文捉急了?
    &為什么要這么規(guī)定? 尤其是 ^^ 好像更適合匹配并替換字符串吧
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP