zoukankan      html  css  js  c++  java
  • Shell案例:图案打印

    打印三角形图案

    #!/bin/bash
    echo "Stars"
    for (( i=1; i<=5; i++ ))
    do
        for (( j=1; j<=i;  j++ ))
        do
         echo -n " *"
        done
        echo ""
    done
    for (( i=5; i>=1; i-- ))
    do
        for (( j=1; j<=i;  j++ ))
        do
         echo -n " *"
        done
        echo ""
    done

    打印菱形案例

    #!/bin/bash
    MAX_NO=0
    echo -n "Enter Number between (5 to 9) : "
    read MAX_NO
    
    if ! [ $MAX_NO -ge 5 -a $MAX_NO -le 9 ] ; then
       echo "???... I ask to enter number between 5 and 9, Try Again"
       exit 1
    fi
    clear
    
    for (( i=1; i<=MAX_NO; i++ ))
    do
        for (( s=MAX_NO; s>=i; s-- ))
        do
           echo -n " "
        done
        for (( j=1; j<=i;  j++ ))
        do
         echo -n " ."
        done
        echo ""
    done
    
    for (( i=MAX_NO; i>=1; i-- ))
    do
        for (( s=i; s<=MAX_NO; s++ ))
        do
           echo -n " "
        done
        for (( j=1; j<=i;  j++ ))
        do
         echo -n " ."
        done
        echo ""
    done
    echo -e "Whenever you need help, I will always here"

    使用帮助命令

    cd命令:

    格式:cd “路径/目录名”

    1绝对路径:从根目录开始写,以“/”打头。

     2相对路径:当前目录的子级目录开始写。

    例如:

    cd  /home/z3切换到/home/z3r目录

    cd /切换到根目录

    cd ..切换到到上一级目录

    cd ../..切换到上二级目录

    cd ~切换到用户目录,比如是root用户,则切换到/root下

  • 相关阅读:
    幻灯片效果
    国外空间乱码的解决方法
    图片自动适应
    css圆角效
    iframe自适应兼容
    css圆角
    图片自动适应2
    JQuery实现智能输入提示(仿机票预订网站)
    AppDiag类
    c# 渐变算法
  • 原文地址:https://www.cnblogs.com/djlsunshine/p/9841682.html
Copyright © 2011-2022 走看看