0
以下腳本正在僅具有csh的HP-UX盒上運行。csh問題從多行檢索輸入
#!/bin/csh -fx
set todaysDate = `date +%m%d%y-%H:%M`
echo -n Paste the email information here:
set input = $<
set info = `echo $input > jcc.$todaysDate`
sed 's/.*\(PL[0-9]*\).*/\1/' jcc.$todaysDate > sample2
echo $info
echo -n Type y if the output is correct or n if it is incorrect
set answer = $<
if($answer == y || $answer == Y) then
#send to other script
else if($Answer == n || $Answer == N) then
exit
else
echo "Invalid input"
endif
它目前沒有檢索到所有需要的值。
這裏是正在鍵入的信息:
Sample
1.-PL000000002002124215 12 DAY 3/11/2013
2.-PL000000002002365287 67 DAY 22/11/2013
3 PL000000002002745214 35 DAY 27/11/2013
基於來自電子郵件的信息,第一行是它獲得存儲在變量的唯一的事。
預期成果是:
PL000000002002124215
PL000000002002365287
PL000000002002745214
謝謝你的回覆@基思 - 湯普森和@shellter!
這是根據您的信息和變化,我做了輸出:
set todaysDate = `date +%m%d%y-%H:%M`
date +%m%d%y-%H:%M
echo -n Paste the email information here:
Paste the email information here:Sample
1.-PL000000002002124215 12 DAY 3/11/2013
set input = Sample
2.-PL000000002002365287 67 DAY 22/11/2013
echo Sample
3 PL000000002002745214 35 DAY 27/11/2013sed s/.*\(PL[0-9]*\).*/\1/ jcc.120913-15:10
echo Sample
Sample
echo -n Type y if the output is correct or n if it is incorrect
Type y if the output is correct or n if it is incorrectset answer = 1.- PL000000002002124215 12 DAY 3/11/2013
if (1.-PL000000002002124215 12 DAY 3/11/2013 == y || 1.-PL000000002002124215 12 DAY 3/11/2013 == Y) then
if: Badly formed number.
homes/ 32% 2.-PL000000002002365287 67 DAY 22/11/2013
2.-PL000000002002365287: Command not found.
homes/ 33% 3 PL000000002002745214 35 DAY 27/11/2013
「只有csh」?如果它至少沒有'/ bin/sh',Bourne shell,它通常被認爲對腳本更好,我會感到驚訝。 –
請考慮編輯您的問題以包含您當前的輸出。從你的主題來看,我猜你只會讓你輸入的第一行回顯。是?通過'set input = $ <'分配數據可能根本無法使用多行輸入OR幾乎肯定會要求您在每行輸入的末尾用'\\'字符替換換行符。祝你好運! – shellter