zoukankan      html  css  js  c++  java
  • shell编程的一些例子5

    1.here文档

    here文档允许我们调用一个交互式程序;可以从脚本程序中输出大量的文本,从而不必echo每行

    例子1:

    #!/bin/bash

    cat<<!DATA!

    This is a simple use of the here document.This data is the 

    input given to the above cat command

    !DATA

    其输出为:

    This is a simple use of the here document.This data is the 

    input given to the above cat command

    例子2(与grep搜索命令的交互):

    demo_dext 文件内容

    #!/bin/bash

    if [ $# -eq 0]

    then

    echo "Usage:$0 name"

    exit 1

    fi

    user_input="$1"

    grep -i $user_input<<!DIRECTORY!

    John Doe   1234567   hahahah

    David Nice  3248428   jjkjkll

    Don Carr   8989897   jkdjasl

    !DIRECTORY!

    exit 0

    执行:

    $chmod u+x demo_dext

    $./demo_dext John

    John Doe   1234567   hahahah

  • 相关阅读:
    梯度下降法
    超平面
    感知机模型
    三角不等式
    统计学习方法基本概念
    Kaggle 的注册和使用
    win10 部署 Anaconda
    全概率和贝叶斯公式
    行列式
    伴随矩阵
  • 原文地址:https://www.cnblogs.com/fengyuehan/p/3448363.html
Copyright © 2011-2022 走看看