日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Study Linux --- Shell Script

發布時間:2024/4/17 linux 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Study Linux --- Shell Script 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
# Exapmle1 : about test command
#
!/bin/bash
#
?Program:
#
?Let?user?input?a?filename,?the?program?will?search?the?filename
#
1.)?exist??2.)?file/directory??3.)?file?permissions?
#
?History:
#
?2005/08/25VBirdFirst?release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export?PATH

#?1.?讓使用者輸入檔名,並且判斷使用者是否真的有輸入字串?
echo?-e?"The?program?will?show?you?that?filename?is?exist?which?input?by?you.\n\n"
read?
-p?"Input?a?filename?:?"?filename
test?
-z?$filename?&&?echo?"You?MUST?input?a?filename."?&&?exit?0
#?2.?判斷檔案是否存在?
test?!?-e?$filename?&&?echo?"The?filename?$filename?DO?NOT?exist"?&&?exit?0

#?3.?開始判斷檔案類型與屬性
test?-f?$filename?&&?filetype="regulare?file"
test?
-d?$filename?&&?filetype="directory"
test?
-r?$filename?&&?perm="readable"
test?
-w?$filename?&&?perm="$perm?writable"
test?
-x?$filename?&&?perm="$perm?executable"
#?4.?開始輸出資訊!
echo?"The?filename:?$filename?is?a?$filetype"
echo?
"And?the?permission?are?:?$perm"
#!/bin/bash
#
#
?這支程式主要在幫您建立大量的帳號之用,
#
?更多的使用方法請參考:
#
?http://linux.vbird.org/linux_basic/0410accountmanager.php#manual_amount
#
#
?本程式為鳥哥自行開發,在?FC4?上使用沒有問題,
#
?但不保證絕不會發生錯誤!使用時,請自行負擔風險~
#
#
?History:
#
?2005/09/05????VBird???剛剛才寫完,使用看看先~
PATH=/sbin:/usr/sbin:/bin:/usr/bin;?export?PATH
accountfile
="user.passwd"

#?1.?進行帳號相關的輸入先!
read?-p?"帳號開頭代碼?(?Input?title?name,?ex>?std?)======>?"?username_start
read?
-p?"帳號層級或年級?(?Input?degree,?ex>?1?or?enter?)=>?"?username_degree
read?
-p?"起始號碼?(?Input?start?number,?ex>?520?)========>?"?nu_start
read?
-p?"帳號數量?(?Input?amount?of?users,?ex>?100?)=====>?"?nu_amount
read?
-p?"密碼標準?1)?與帳號相同?2)亂數自訂?==============>?"?pwm
if?[?"$username_start"?==?""?];?then
????????echo?
"沒有輸入開頭的代碼,不給你執行哩!"?;?exit?1
fi
testing1
=`echo?$nu_amount?|?grep?'[^0-9]'?`
testing2
=`echo?$nu_start??|?grep?'[^0-9]'?`
if?[?"$testing1"?!=?""?]?||?[?"$testing2"?!=?""?];?then
????????echo?
"輸入的號碼不對啦!有非為數字的內容!"?;?exit?1
fi
if?[?"$pwm"?!=?"1"?];?then
????????pwm
="2"
fi

#?2.?開始輸出帳號與密碼檔案!
[?-f?"$accountfile"?]?&&?mv?$accountfile?"$accountfile"`date?+%Y%m%d`
nu_end
=$(($nu_start+$nu_amount-1))
for?((?i=$nu_start;?i<=$nu_end;?i++?))
do
????????account
=$username_start$username_degree$i
????????
if?[?"$pwm"?==?"1"?];?then
????????????????password
="$account"
????????
else
????????????????password
=""
????????????????test_nu
=0
????????????????until?[?
"$test_nu"?==?"8"?]
????????????????do
????????????????????????temp_nu
=$(($RANDOM*50/32767+30))
????????????????????????until?[?
"$temp_nu"?!=?"60"?]
????????????????????????do
????????????????????????????????temp_nu
=$(($RANDOM*50/32767+30))
????????????????????????done
????????????????????????test_nu
=$(($test_nu+1))
????????????????????????temp_ch
=`printf?"\x$temp_nu"`
????????????????????????password
=$password$temp_ch
????????????????done
????????fi
????????echo?
"$account":"$password"?|?tee?-a?"$accountfile"
done

#?3.?開始建立帳號與密碼!
????????cat?"$accountfile"?|?cut?-d':'?-f1?|?xargs?-n?1?useradd?-m
????????chpasswd?
<?"$accountfile"
????????pwconv
echo?
"OK!建立完成!"


轉載于:https://www.cnblogs.com/shipfi/archive/2006/04/21/380995.html

總結

以上是生活随笔為你收集整理的Study Linux --- Shell Script的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。