FaceBro
FaceBro

Reputation: 859

Open file using exec in shell failed

Need to open some file for read in shell:

exec 4<$lock

But failed. The error message is:

Line 196: exec: 4: not found

Is there any insight?

Upvotes: 0

Views: 290

Answers (1)

John1024
John1024

Reputation: 113814

That looks like exec is trying to run a program called 4.

I can reproduce that error message by putting a space between 4 and <somefilename, as in:

$ ( exec 4 <somefilename )
bash: exec: 4: not found

See if your script has a misplaced space.

Upvotes: 2

Related Questions