Skip to content
Advertisement

while running this programe i occured one error as ambigous redirect

This is my following bash script

JavaScript

And I receive this kind of error:

./l7.sh: line 12: $file_name: ambiguous redirect

Here are the full code

https://github.com/vats147/public/blob/main/l7.sh

And Why I am getting this error? even my syntax is correct.

Advertisement

Answer

Into the parameter file_name you must assign $1, which will pass to the current file as an input parameter.

JavaScript

These are positional arguments of the script.

Executing ./script.sh Hello World will make

JavaScript

Note

If you execute ./script.sh, $0 will give output ./script.sh but if you execute it with bash script.sh it will give output script.sh.

Advertisement