For general-purpose scenarios, I suggest going through Bash completely.
Bash is probably the most common shell, and your script will work on most * nix systems. In contrast, PHP will not always be easily accessible. Of course, if you are not going to use these scripts in comparison with an unfamiliar system, you will be fine with both.
However, most standard shell commands are easier to write in Bash and then in php. In php, you have to open subprocesses, execute shell commands through some wrapper functions or something not in Bash, you would just write your Bash session in a file, making it executable. Take a directory listing, for example, in Bash just specify ls , and in php you will probably use scandir which is not so much fun. I would also suggest that scandir has much fewer sorting options. grep -Ri something . is anyone
Most general-purpose languages ββcan be used for shell scripts, but this does not mean that they should be, and in the end it comes down to task execution and subjective preference.
Davor lucic
source share