linux之Shell
发布日期:2021-05-10 23:53:50 浏览次数:9 分类:精选文章

本文共 4865 字,大约阅读时间需要 16 分钟。

������������Linux���������Shell

���������������������������������������������Shell���������

cat /etc/shells

������������������������

  • ������������������������������������������

    ������������������������������������

    chmod +x first.sh

    ���������������

    ./first.sh
  • ������shell���������������

    sh script_file.sh arguments
  • ������source���������������

    source script_file.sh arguments
  • ���������������

    ������������/������/������������������������

    • ������������������������������������������

      ���������������������������������

      command > output_file

      ���������������������������������

      command >> output_file
    • ������������������������

      ���������������������������������

      command 2> error_file

      ���������������������������������

      command 2>> error_file
    • ���������������������������������������������

      ���������������������������������

      command &> output_file

      ���������������������������������

      command &>> output_file

    ���������������������

    ������������������������������������������������������������������������������

    grep ���bash$��� /etc/passwd | awk -F: '{print $1,$7}'

    ������Shell������

  • ���������������

    • ������������������������������������������������������
    • ������������������������������������������������������������
    • ������������������������������������������������������������
    • ������������������Bash������������������������������������������
  • ���������������

    ������������������������

    • ���������������������������������������������������������
    • ������������������
    • ���������������������$������������������������������
    • ���������������������������������������
    • ������������������������������
  • ���������������

    num1=100num2=200num3="$num2"num4='$num2'
  • ������������������������

    read NAME

    ���

    read "���������������������" NAME
  • ���������������������

    • ������ export ������������������������������������
    • export variable=value ���������������������������������
  • ���������������

    ������ expr ������������

    sum1=`expr $num1 + $num2`product1=`expr $num1 \* $num2`

    ��������� ((num1 + num2))���

  • ������������������

    ���������������������������������������������������������������������������������������

    • PWD���������������������
    • PATH������������������������
    • USER������������������������
    • SHELL���������Shell������
    • HOME������������������������

    ������������������

    ��������������������� $n���n ��� 1~9���������������������������

    #!/bin/bashcp $1 $2

    <span color "#2e75b5;">���������������������

    ������������������������

    • $#���������������������������������������
    • $*���������������������������������
    • $?������������������������������������
    • $0������������������������������

    ������������������������

  • ������������������������������

    cd /rootvi first.shpwdls -lh vml*chmod +x first.sh./first.sh
  • ���������������

    #!/bin/bashcp $1 $2
  • ���������������������

    crontab -e30 2 * * * /bak.shservice crond start
  • ������������������

    ������������������

  • ������������������������

    • -d���������������������������
    • -e���������������������������������������
    • -f���������������������������
    • -r���������������������������������������������
    • -w���������������������������������������������
    • -x���������������������������������������������
  • ���������������

    • ||���������������
    • &&���������������
    • !���������������
  • ������������������������

    • =���������������������������
    • !=���������������������������
    • -z���������������������������
  • ������������������������������������������

    free -mecho "���������������$(free -m | grep "Mem:")" echo "���������������$(free -m | grep "New:)")

    ������������������Httpd������������������

    netstat -anpt | grep httpd > /dev/nullif [ $? -eq 0 ]; then  echo "Httpd���������������������"  service httpd startelse  rpm -q httpd > /dev/null  if [ $? -eq 0 ]; then    echo "Httpd���������������������������������..."    service httpd start  else    rpm -ivh /mnt/Packages/httpd-2.2.15-29.el6_4.x86_64.rpm    echo "������������������������������Httpd..."  fifi

    ���������������������������������������������������

    echo -e "������������������������0-100������������"read scoreif [ $score -ge 90 -and $score -le 100 ]; then  echo "������"elif [ $score -ge 70 -and $score -le 89 ]; then  echo "������"else  echo "������"fi

    ���������������������������������

    nc -zv 192.168.1.1 80if [ $? -eq 0 ]; then  echo "������������������������������������!"else  echo "������������������������������������������!"fi

    ������������������������������

    #!/bin/bashfor ((i=1; i<=100; i++)); do  useradd stu$i > /dev/null  echo "123456" | password --stdin stu$idone

    ���������������������������

    echo "������������������������!"read -p "������������������������1-100������" numberif [ $number -ge 1 -and $number -le 100 ]; then  secret_number=$((15 * $number + 15))  echo "���������������������$secret_number������"  read -p "���������������������������" guess  if [ $guess -eq $secret_number ]; then    echo "���������������������������"  else    echo "������������������������������"$secret_number  fielse  echo "������������������������1-100������������������������"fi
    上一篇:linux之系统资源管理
    下一篇:linux之Mysql数据库基础及安全配置

    发表评论

    最新留言

    第一次来,支持一个
    [***.219.124.196]2025年04月09日 01时16分05秒