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

  免費注冊 查看新帖 |

Chinaunix

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

[文本處理] 【求助】幫忙改錯 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2013-08-20 10:25 |只看該作者 |倒序瀏覽
題目:
Write a script named nonwords that is passed a file containing one word per line, and checks to see if each word exists.
nonwords 輸出在“字典文件”沒有找到的單詞,一行一個.
Once again, accept input from a file or from standard input.
不區(qū)分大小寫;
Extend your nowords script to include a -i option that ignores any final “s” on each word (if there is one), and then checks to see if the word exists.

我的解法:
#!/bin/bash

if [[ $1 = "-i" ]]; then    #判斷是否含有-i參數(shù)
        while (read word )
        do
        l_char=$(echo $word | grep -i -o '.$')     #取出最后一個字符
        if [ $l_char = 's' ];then
                n_word=$(echo $word | sed s/.$//)     #如果是s就刪除
        else
                n_word=$word              #否則直接賦值到新的變量中
        fi
                if ( ! grep -iqw $n_word $3)        #不區(qū)分大小的情況下比較變量和字典文件,如果不存在就輸出
                then
                        echo $n_word
                fi
        done < $2         #繼續(xù)讀取

else                               #如果沒有-i參數(shù),就直接進(jìn)行簡單步驟
        while (read word)
        do
        if (! grep -iwq word $3)
        then
                echo $word
        fi
        done < $1
fi


我在自己電腦上中執(zhí)行語句是:
./nonword check.txt dict.txt

./nonword -i check.txt dict.txt
執(zhí)行沒有問題


但是在學(xué)校的在線系統(tǒng)中檢測會報錯:
./nonwords: line 26: $1: ambiguous redirect
...Your nonwords cannot handle words from stdin
...Your nonwords cannot handle words from a file
./nonwords: line 26: $2: ambiguous redirect
...Your nonwords cannot handle the -i option


雖能告訴我怎麼改正?

論壇徽章:
5
未羊
日期:2014-08-04 16:15:21天秤座
日期:2014-08-13 13:52:372015年辭舊歲徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:112015亞冠之浦和紅鉆
日期:2015-06-29 15:30:48
2 [報告]
發(fā)表于 2013-08-20 11:32 |只看該作者
shell環(huán)境不一樣,這個具體情況具體分析吧

論壇徽章:
145
技術(shù)圖書徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11獅子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龍
日期:2014-01-08 15:26:12技術(shù)圖書徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
3 [報告]
發(fā)表于 2013-08-20 17:22 |只看該作者
回復(fù) 1# ICrazyBox

please try to add -x to find the detail issue ...

#!/bin/bash -x

or

#!/bin/bash
set -x

   

論壇徽章:
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
4 [報告]
發(fā)表于 2013-08-20 17:35 |只看該作者
學(xué)校的在線系統(tǒng)用的什么系統(tǒng)
  1. uname -a
  2. bash --version
復(fù)制代碼
結(jié)果貼出來看看

腳本從windows里面復(fù)制過去的嗎?
  1. dos2unix ./nonword
復(fù)制代碼
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(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