shell电话本Word格式.docx

上传人:b****6 文档编号:16635016 上传时间:2022-11-25 格式:DOCX 页数:15 大小:17.17KB
下载 相关 举报
shell电话本Word格式.docx_第1页
第1页 / 共15页
shell电话本Word格式.docx_第2页
第2页 / 共15页
shell电话本Word格式.docx_第3页
第3页 / 共15页
shell电话本Word格式.docx_第4页
第4页 / 共15页
shell电话本Word格式.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

shell电话本Word格式.docx

《shell电话本Word格式.docx》由会员分享,可在线阅读,更多相关《shell电话本Word格式.docx(15页珍藏版)》请在冰豆网上搜索。

shell电话本Word格式.docx

)}

{for(i=1;

i<

=NF;

i++){

if($i!

="

){

printarry[i]"

"

$i"

\n"

}

print"

system("

sleep1"

}'

./phone.bak

else

cat./phone.bak

fi

print_name(){

{print"

$1;

if($5!

="

){print"

Phone:

$5"

}else{print"

PhoneisNull\n"

}}'

./phone.bak

cut-d'

-f1,5./phone.bak

fi

add_rec(){

read-p"

Name:

name

$name"

="

qqq"

return0

Nicename:

nicename

Work:

work

get_pho_num(){

Phone_number:

phone_num

if[[${#phone_num}!

=11]]

then

echo"

Wrongphonenumber,tryagin"

get_pho_num

else

echo$phone_num

echo"

$phone_num"

|grep-E"

[[:

punct:

]]|[[:

alpha:

]]"

if[[$?

=0]]

then

echo"

Thenumberiswrong,tryagin"

get_pho_num

else

cut-d'

-f5./phone.bak|grep"

then

Thenumberhasextesed,tryagin"

else

return0

fi

fi

}

get_loc_num(){

Locale_nmber:

local_num

if[[${#local_num}<

7]]

get_loc_num

`echo"

$local_num"

`&

&

&

get_bir(){

BirthdayYYYY-MM-DD:

birthday

if(date-d"

$birthday"

+"

%Y-%m-%d"

birthday=`date-d"

`

Thebirthdayiswrong,tryagin"

get_bir

get_mail(){

E-mail:

mail_a

if(echo"

$mail_a"

|grep-E"

.+@.+\.com"

TheE-mailiswrong,tryagin"

get_mail

get_qq(){

QQ/MSN:

qq

if[["

${#qq}"

<

5]]

TheQQ/MSNiswrong,tryagin"

get_qq

}

Address:

address

Remarks:

remarks

lastnum=`cut-d'

-f2phone.bak|sort-n|tail-1`

letnumber=${lastnum:

=0}+1

$name:

$number:

$nicename:

$work:

$phone_num:

$local_num:

$birthday:

$mail_a:

$qq:

$address:

$remarks"

>

./phone.bak

first_menu(){

cat<

<

EOF2

=========================FirstUserMenu===========================

1)AddNewRecords

R)GoMainMenuAfterAdd

Q)Quit

===================================================================

while:

do

echo

read-n1-p"

MainMenu1|Rr|Qq"

menu2

echo

case"

$menu2"

in

1)add_rec

;

;

R|r)return

Q|q)exit

#*)echo"

Badchoice"

#;

esac

done

search_spe(){

key_word="

$2"

echo$key_word

case$1in

name)

-f1./phone.bak|grep$key_word|grep-f-./phone.bak

number)

-f5./phone.bak|grep$key_word|grep-f-./phone.bak

qq)

-f9./phone.bak|grep$key_word|grep-f-./phone.bak

all)

grep$key_word./phone.bak

esac

search_menu(){

while:

do

echo

=============================SearchMenu============================="

1)SearchByName"

2)SearchByPhoneNumber"

3)SearchByQQ/MSN"

4)SearchInAll"

R)RetrunToMainMenu"

===================================================================="

SearchMenu1-4|Rr#"

sear

$sear"

r"

-o"

R"

return

Enteryourkeyword:

word

1)search_spename$word

2)search_spenumber$word

3)search_speqq$word

4)search_speall$word

R|r)return0

done

del_rec(){

EnterThenameyouwantdelete"

dn

["

$dn"

]&

sed-n'

/^'

/p'

Therecordyoutrytodelete...y|n|q"

re

$re"

y'

sed-i'

/d'

elif["

n'

del_rec

del_menu(){

=============================DelMenu==============================="

1)DeleteByName"

2)DeleteAllRecord"

====================================================================="

DelMenu1-2|Rr#"

del

$del"

1)del_rec

2)read-n1-p"

AreYouSurey|n"

sure

$sure"

]

rm-rf./phone.bak

touch./phone.bak

del_menu

done

mod_rec(){

EnterThenameyoutrytomodify:

mod_name

awk'

BEGIN{FS="

split("

{

if($1=="

$mod_name'

{

for(i=1;

i++)

if(i==2)

continue

printfarry[i]"

\t\t\tNew"

arry[i]"

getlinearry_new[i]<

-"

if(arry_new[i]=="

arry_new[i]=$i;

if(i==5)

{print"

thisis:

arry_new[5];

if(length(arry_new[5])!

=11||arry_new[5]~/[a-z]/||arry_new[5]~/[[:

]]/)

{

print"

Thenumberiswrongtryagin"

i--;

}

if(i==6)

if(length(arry_new[6])<

7||arry_new[6]~/[a-z]/||arry_new[6]~/[[:

if(i==7)

if(arry_new[7]!

~/^[12][09][0-9][0-9]-[01][0-9]-[123][0-9]$/)

Thedayiswrong,tryagin"

if(i==8)

if(arry_new[8]!

~/.+@.+\.com$/)

TheE-mailiswrong,tryagin"

arry_new[2]=$2;

sleep3"

);

if(NR==1)

Makesurethenameisright."

Modifycomplet"

}END{for(j=1;

j<

=11;

j++)

if(j!

=11)

printfarry_new[j]"

./.phonebook_awk.bak"

if(j==11)

}'

line_num=`cut-d'

-f2./.phonebook_awk.bak`

line_numis:

$line_num

/.*:

$line_num"

.*/d'

cat./.phonebook_awk.bak>

rm./.phonebook_awk.bak-rf

bak_mail(){

mail_add

$mail_add"

mail-s"

phone.bat"

./phone.bak>

/dev/null2>

1

ThenE-mailiswrong,Nowsendthemailwithdefaultmail_address"

395423101@"

main(){

test-f./phone.bak||touch./phone.bak

cp./phone.bak./.phone.bat

test-s./phone.bak||first_menu

EOF5

=============================MainMenu=============================

1)PrintAllCurrentRecords

2)PrintAllCurrentRecords(formatted)

3)PrintNamesandPhoneNumbers

4)PrintNamesandPhoneNumbers(formatted)

5)SearchforspecificRecord(s)

6)AddNewRecords

7)DeleteRecords

8)ModifyRecords

9)BackuptoMail

R)ReflashScreen

Q)Quit

====================================================================

MainMenu0-9|Rr|Qq#"

menu

$menu"

1)print_all

2)print_allf

3)print_name

4)print_namef

5)search_menu

6)add_rec

7)del_menu

8)mod_rec

9)bak_mail

Q|q)ex_menu

R|r)clear

main

rm-rf./.phone.bat

passwordaaa(){

if(grep-E"

^password$"

./phonebook.sh)

Enterserailnumber:

numb

$numb"

1234512345"

s/^passwordaaa$/#&

/'

./phonebook.sh

passwordaaa

passwordaaa

main

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 其它

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1