"Text File Busy" when running a simple script on bash

When I make a simple script, I get "Text File Busy" when I try to run it.

dbell@det-ui-supergbe:~$ cat > test2
ls
^Z
[2]+ Stopped cat > test2
dbell@det-ui-supergbe:~$ chmod a+x test2
dbell@det-ui-supergbe:~$ ./test2
-bash: ./test2: Text file busy

1 Answer

By hitting Ctrl-Z you suspended the cat, therefore the file is still open and being written to "in the background".

I suspect you want Ctrl-D for 'end of file'.

It's true that Ctrl-Z can mean 'EOF', but in this case, because you're in a terminal that supports background tasks, Ctrl-Z means 'suspend'.

Try this link for more information.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like