Bash Function -> Command not found

前端 未结 4 968
后悔当初
后悔当初 2021-01-17 11:11

Hi gusy I am trying to learn Bash and cannot seem to get this basic script to work.

#!/bin/bash

function system_info
{    
    echo \"function system_info\"         


        
4条回答
  •  野的像风
    2021-01-17 11:31

    #!/bin/bash
    
    function system_info
    {    
        echo "function system_info"
    }
    
    echo $(system_info)
    

    Kind of redundant but it works without the command not found error.

    Or This:

    #!/bin/bash
    
    function system_info
    {    
      echo "function\n system_info"
    }
    
    printf "$(system_info)"
    

    If you want to use newline character.

    You can try this code in: https://www.tutorialspoint.com/execute_bash_online.php

提交回复
热议问题