shell編程例子 -- 一個簡單的目錄菜單

root@desktop:~/bash# cat directory.sh
#!/bin/bash

until
    echo List Directory..........1
    echo Change Directory........2
    echo Edit File...............3
    echo Remove File.............4
    echo Exit Menu...............5

    read choice
    test $choice = 5
    do
        case $choice in
        1) ls;;
        2) echo Enter target directory
           read dir
           cd $dir
           ;;
        3) echo Enter file name
           read file
           vi $file
           ;;
        4) echo Enter file name
           read file
           rm $file
           ;;
        q|Q|5) echo Goodbye;;
        *) echo illegal Option
    esac
done
root@-desktop:~/bash#



因為各種原因,你可能不想讓某個用戶登陸在系統上,下面的腳本可以幫助你實現這個願望:

[root@foo /]# while true
> do
> kill -9 $(ps -aux |grep username | awk '{ print $2 }' )
> sleep 2
> done

 

 

shell編程例子 -- 一個簡單的目錄菜單


until
    echo List Directory..........1
    echo Change Directory........2
    echo Edit File...............3
    echo Remove File.............4
    echo Exit Menu...............5

    read choice
    test $choice = 5
    do
        case $choice in
        1) ls;;
        2) echo Enter target directory
           read dir
           cd $dir
           ;;
        3) echo Enter file name
           read file
           vi $file
           ;;
        4) echo Enter file name
           read file
           rm $file
           ;;
        q|Q|5) echo Goodbye;;
        *) echo illegal Option
    esac
done (http://www.fanqiang.com





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值