zoukankan      html  css  js  c++  java
  • 学习Linux第七天

    1.shell

    echo $HOME

    默认在shell中编写的变量全部是局部变量,如果重新打开console的话,那么这些变量将全部丢失,全局的变量可以写在文件~/.bashrc文件。

    2.判断

    !/bin/sh
    #if-elif-else-fi
    user_input_fruit = "";
    echo -e "please input a kind of fruit:
    ";
    read user_input_fruit;
    if [ $user_input_fruit = "apple" ]
    then
        echo -e "You input e[1;32mAPPLEe[0m!
    ";
    elif [ $user_input_fruit = "grape" ]
    then
        echo -e "You input e[1;34mGRAPEe[0m!
    ";
    else
        echo -e "Please input a kind of e[1;36mFRUITe[0m!
    ";
    fi

    3.循环

    !/bin/sh
    #for-do-done
    user_input_number=1;
    echo "please input a number:";
    read user_input_number;
    i=0;
    for (( $i=0; $i<$user_input_number; $i++))
    do
        echo $i,"
    ";
    done
    !/bin/sh
    #while loop
    n=10;
    i=0;
    while [ $i -le $n ]
    do
        echo $i." ";
    done
    !/bin/sh
    #case-in-;;-esac
    user_input_genda="male";
    echo "tell me your genda:
    ";
    read user_input_gendar;
    case $user_input_gender in
        "male")
            echo "Wo, good man
    ";;
        "female")
            echo "Ohh,smart girl
    ";;
        *)
            echo "You must be jokking
    ";;
    esac
  • 相关阅读:
    css随笔7
    css随笔6
    css随笔5
    *css随笔4
    css3随笔3
    css随笔2
    css随笔1
    HTML总结
    HTML随笔2
    消息转发原理
  • 原文地址:https://www.cnblogs.com/hujun1992/p/linux-7.html
Copyright © 2011-2022 走看看