(D)プライマリテキスト処理ツールやスクリプトの仕事

1、/ etc / passwdファイルのシェルユーザー/ sbinに/ nologinにデフォルト以外の数の統計、およびユーザーが表示されます

cat /etc/passwd | grep -v '\/sbin\/nologin$' | wc -l
cat /etc/passwd | grep -v '\/sbin\/nologin$' | cut -d':' -f1

2、最大UID、UIDおよびシェルタイプを検出するために、ユーザのユーザ名

cat /etc/passwd | sort -nr -t':' -k3 | head -1 | cut -d':' -f1,3,7 | tr ':' ' '

機械プレス降順の各リモート・ホストのIPのための現在の接続統計に接続されている3、

ss -an | tr -s ' ' | cut -d' ' -f6 | sed -rn '/[0-9]+\:[0-9]+$/p' | cut -d':' -f1 | sort | uniq -c | sort -rn

ユーザ指定のパラメータは、その存在を示すために存在する場合は、パラメータとしてユーザ名を使用して、またはそれに追加し、表示情報をユーザID番号などを追加する:図4は、スクリプトcreateuser.shは、以下の機能を実現します

vim createuser.sh

read -p "Please enter username: " UserName
id $UserName &> /dev/null && echo -e "\033[31mUser exist\033[0m" || useradd $UserName;cat /etc/passwd | grep $UserName

図5は、作成者、連絡先情報、バージョン、時間、及び説明など、スクリプト生成されたスクリプトの基本的な形式を記述します

vim .vimrc

autocmd BufNewFile *.py,*.cc,*.sh,*.java exec ":call SetTitle()"
func SetTitle()
    if expand ("%:e") == 'sh'
        call setline(1, "#!/bin/bash")
        call setline(2, "#Author:Rick")
        call setline(3, "#Time:".strftime("%F %T"))
        call setline(4, "#Name:".expand("%"))
        call setline(5, "#Version:V1.0")
        call setline(6, "#Description:This is a production script.")
        call setline(7, "")
    endif
endfunc

おすすめ

転載: blog.51cto.com/14599947/2452842