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

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問板塊 發(fā)新帖
查看: 3423 | 回復(fù): 9
打印 上一主題 下一主題

[文本處理] 關(guān)于sed if esle [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2015-08-26 16:48 |只看該作者 |倒序?yàn)g覽
主要是一直沒有系統(tǒng)的學(xué)習(xí)shell 一般是由什么需要就來問  也能得到相應(yīng)的回答。。。
最近發(fā)現(xiàn)sed也可以用if else
但是貌似就論壇上有 而且解釋的不怎么詳細(xì)
所以出去找了找 果斷發(fā)現(xiàn)了
pement.org/sed/ifelse.txt

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2015-08-26 16:49 |只看該作者
沒權(quán)限發(fā)鏈接。。。前面加3w就好了
具體類容
IF/ELSE TESTING IN SED

----------
This message was originally posted on the seders mailing list in 1998.
It has been lightly edited for general readers. In answer to the
question:

> Are there any standard/short-cuts for
>
>     if (test) then action1 else action2

Yes, there are several ways of expressing IF/ELSE logic. For example:

  # -------------------------------------------
  # one-line actions, for if (test) then action1, else action2
  # -------------------------------------------
  /test/s/$/ action1/;     # if /test/ is found, append action1 to EOL
  /test/!s/$/ action2/;    # if /test/ not found, append action2

  /test2/d;                # if /test2/ is found, delete line. The
                           # implied ELSE is to print the line.

  /test3/!y/ABCDE/abcde/;  # if /test3/ is missing, lowercase A-E.
                           # The implied ELSE is leave A-E alone.

  # -------------------------------------------
  # multi-line actions showing IF/ELSE usage
  # -------------------------------------------
  /test4/{                 # if /test4/ is found, ...
     s/$/aaa/;             # ... perform these actions
     s/[0-9]/number/;
     s/test5/YYY/;         # Boolean /test4/ && /test5/
  }

  /test4/!{                # if /test4/ is missing, ...
     s/^/bbb/;             # ... perform these instead
     s/[a-f]/letter/;
     s/test6/ZZZ/;         # Boolean /test4/! && /test6/
  }

  /test7/b next            # if /test7/ is found, skip the next cmds
    s/$/new tail/;         # else: 1) add a new ending to each line
    /^/a\                  #       2) and append new line after each
    APPENDED WORDS AFTER EACH LINE

    /test8/d;              #       3) and delete each line with /test8/
  : next

  # Next routine will fail under GNU sed 2.05, due to a bug
  s/test9/&/6;             # if /test9/ appears 6 times or more,
  t next2                  # ... jump to label :next2 for commands
  cmd1;cmd2;cmd3;          # else, do these 3 commands
  b next3                  # the ELSE stops here
  : next2                  # the next 3 commands are executed only
  cmd4;cmd5;cmd6;          # ... if /test9/ was found 6 times
  : next3                  # this corresponds to ENDIF


  /test9/ { /test10/ {     # Boolean IF /test9/ && /test10/ are true,
    cmd1; cmd2; cmd3;      # ... do these 3 commands
    b next4
    }                      # ELSEIF /test9/ && /test10/! are true,
    cmd4; cmd5; cmd6;      # ... do cmd4, cmd5, and cmd6
    b next4
  }                        # ELSE,
  cmd7; cmd8; cmd9;        # ... do cmd7, cmd8, and cmd9
  : next4                  # This corresponds to ENDIF


   I have liberally added comments to explain these commands. Normally,
comments are only supported in GNU sed, HHsed, and HP-UX sed, and they
should be preceded by the semicolon after the command and before the
pound sign (#). Further, comments are almost NEVER supported after
commands which take a word argument (b,t,r,w), after :labels, or after
a,i,c commands. I have put comments after labels and branch commands to
make the explanation easier to follow, but don't use them in real sed
scripts. Hope this helps.

Kind regards,

Eric Pement
--
Eric Pement <pemente@bnorthpark.edu>
maintainer of the sed FAQ file
sed FAQ file:  3w.faqs.org/faqs/editor-faq/sed
sed for DOS:  p://student.northpark.edu/pemente/sed/

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2015-08-26 16:51 |只看該作者
發(fā)現(xiàn)  能找到答案是一回事  找到對(duì)應(yīng)答案自己使用 是一回事  自己知道答案是一回事。。。

論壇徽章:
780
金牛座
日期:2014-02-26 17:49:58水瓶座
日期:2014-02-26 18:10:15白羊座
日期:2014-04-15 19:29:52寅虎
日期:2014-04-17 19:43:21酉雞
日期:2014-04-19 21:24:10子鼠
日期:2014-04-22 13:55:24卯兔
日期:2014-04-22 14:20:58亥豬
日期:2014-04-22 16:13:09獅子座
日期:2014-05-05 22:31:17摩羯座
日期:2014-05-06 10:32:53處女座
日期:2014-05-12 09:23:11子鼠
日期:2014-05-21 18:21:27
4 [報(bào)告]
發(fā)表于 2015-08-26 16:54 |只看該作者
回復(fù) 1# Piaomiao139

論壇里比這個(gè)清楚得多的學(xué)習(xí)資料一搜一大堆,
我記得Tim大師就寫過.
   

論壇徽章:
0
5 [報(bào)告]
發(fā)表于 2015-08-26 16:57 |只看該作者
其實(shí)他本身就是一個(gè)判斷  只是一直沒想到。。。

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2015-08-26 17:06 |只看該作者
回復(fù) 4# Herowinter


    沒找到到 if else的

論壇徽章:
95
程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-05 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-17 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-09-18 06:20:002015亞冠之阿爾艾因
日期:2015-09-18 10:35:08月度論壇發(fā)貼之星
日期:2015-09-30 22:25:002015亞冠之阿爾沙巴布
日期:2015-10-03 08:57:39程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-10-05 06:20:00每日論壇發(fā)貼之星
日期:2015-10-05 06:20:002015年亞冠紀(jì)念徽章
日期:2015-10-06 10:06:482015亞冠之塔什干棉農(nóng)
日期:2015-10-19 19:43:35程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-10-21 06:20:00每日論壇發(fā)貼之星
日期:2015-09-14 06:20:00
7 [報(bào)告]
發(fā)表于 2015-08-26 17:08 |只看該作者
Piaomiao139 發(fā)表于 2015-08-26 17:06
回復(fù) 4# Herowinter

沒找到到 if else的


人家叫條件跳轉(zhuǎn).

論壇徽章:
0
8 [報(bào)告]
發(fā)表于 2015-08-26 17:13 |只看該作者
回復(fù) 7# MMMIX


    好吧。。。

論壇徽章:
33
ChinaUnix元老
日期:2015-02-02 08:55:39CU十四周年紀(jì)念徽章
日期: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科比退役紀(jì)念章
日期:2022-04-24 14:33:24
9 [報(bào)告]
發(fā)表于 2015-08-28 14:33 |只看該作者

論壇徽章:
22
處女座
日期:2014-10-11 13:33:292015亞冠之塔什干火車頭
日期:2015-07-20 19:59:042015亞冠之塔什干火車頭
日期:2015-07-26 10:59:31程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-08-05 06:20:00每日論壇發(fā)貼之星
日期:2015-08-05 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-08-07 06:20:00每日論壇發(fā)貼之星
日期:2015-08-07 06:20:002015亞冠之阿爾納斯?fàn)?日期:2015-10-01 15:23:28白銀圣斗士
日期:2015-12-07 17:17:06操作系統(tǒng)版塊每日發(fā)帖之星
日期:2015-12-27 06:20:002015亞冠之廣州富力
日期:2015-07-08 15:48:31程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-06-11 22:20:00
10 [報(bào)告]
發(fā)表于 2015-08-29 23:42 |只看該作者
sed 的”else if“ 貌似是通過標(biāo)簽跳轉(zhuǎn)實(shí)現(xiàn)的
您需要登錄后才可以回帖 登錄 | 注冊(cè)

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

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP