Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

steeldriver is correctsteeldriver is correct. What you should do is either:

  1. Use a command that reads in the standard input:

     #!/bin/bash
    
     fun=$(cat)
     echo "$fun"  
    

Or simply:

    #!/bin/bash
    
    cat
  1. Or, to convert standard input into positional parameters, use xargs:

     $ echo 1 | xargs ./test.sh
    
  2. Or, use the script the way it is supposed to be used (as coded):

     ./test.sh 1
    

steeldriver is correct. What you should do is either:

  1. Use a command that reads in the standard input:

     #!/bin/bash
    
     fun=$(cat)
     echo "$fun"  
    

Or simply:

    #!/bin/bash
    
    cat
  1. Or, to convert standard input into positional parameters, use xargs:

     $ echo 1 | xargs ./test.sh
    
  2. Or, use the script the way it is supposed to be used (as coded):

     ./test.sh 1
    

steeldriver is correct. What you should do is either:

  1. Use a command that reads in the standard input:

     #!/bin/bash
    
     fun=$(cat)
     echo "$fun"  
    

Or simply:

    #!/bin/bash
    
    cat
  1. Or, to convert standard input into positional parameters, use xargs:

     $ echo 1 | xargs ./test.sh
    
  2. Or, use the script the way it is supposed to be used (as coded):

     ./test.sh 1
    
Source Link
muru
  • 78.1k
  • 16
  • 213
  • 319

steeldriver is correct. What you should do is either:

  1. Use a command that reads in the standard input:

     #!/bin/bash
    
     fun=$(cat)
     echo "$fun"  
    

Or simply:

    #!/bin/bash
    
    cat
  1. Or, to convert standard input into positional parameters, use xargs:

     $ echo 1 | xargs ./test.sh
    
  2. Or, use the script the way it is supposed to be used (as coded):

     ./test.sh 1