I have a directory with a huge number of files. I want to write a bash script to -
- Enter that directory
- Find out which of them are Perl scripts (but none of them have a .pl extension)
- Add a line at the top of each of the line (I intend to add a new shebang) If not a Perl script, do nothing
I am unable to search for the Perl scripts, tried using grep but not getting the proper command. Also, the third step is also where I am stuck.
There is no way to insert data at the beginning of a file, all you can do is create a new file, write the additional data, and append the old data. So you'll have to rewrite the whole file at least once to insert the first line
.