Shell script multi-line comment

后端 未结 5 1914
傲寒
傲寒 2021-01-03 09:32

I am having a large shell script file. At times while doing modification I want to comment out part of it. But commenting line as shown in the below example is giving me e

5条回答
  •  没有蜡笔的小新
    2021-01-03 09:53

    if this is not a syntax error (open string, ...)

    #!/bin/bash
    
    if false;then
    read build_label
    read build_branch_tag
    build_date_tag=$(echo $build_label | sed "s/$build_branch_tag//g")
    echo $build_path
    fi
    
    echo "HELLO WORLD"
    

    if sysntax error or equivalent (unfound place like in search of error by descativate part of failing code)

    #!/bin/bash
    
    #read build_label
    #read build_branch_tag
    #build_date_tag=$(echo $build_label | sed "s/$build_branch_tag//g")
    #echo $build_path
    
    echo "HELLO WORLD"
    

    for this you can use: - editor if find/replace with regex is available like vi(m) - a sed (sed '14,45 s/^/#/' YourFile > YourFile.Debug where 14 and 45 are first and last lines to comment)

提交回复
热议问题