I have a string with the contents of the first line in a script, eg
#!/bin/bash
but it can be anything such as
#!/path/to/another/interpret -some args -another arg
How can I extract the name of the interpreter – “bash”, “interpret” by omitting path and arguments?
I though about finding the first whitespace to separate args from the path.
Can you help?
I don’t think you can use white spaces in shebang. If you cannot, you can find the interpreter name like this:
edit:
shorten version: