Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • How are you determining which files are bash scripts? Commented Feb 15, 2021 at 2:00
  • @NasirRiley This is the main problem actually, idk how to determine only bash script files Commented Feb 15, 2021 at 2:04
  • The file command is not overly reliable. For example, create a script that starts with twenty comment lines other than #!/bin/bash. file will categorize it as ASCII text (at least my version of file does). Commented Feb 15, 2021 at 2:06
  • 1
    If you trust file, you can generate the list of shell scripts with file * | grep shell | cut -f1 -d: (assuming filenames don't contain colons). You step through this list with a for loop and rename the files. Commented Feb 15, 2021 at 2:07
  • @berndbausch note that the #!/bin/bash line must always be the first line; anything not on the first line is ignored (and the kernel will run the script with /bin/sh) Commented Feb 15, 2021 at 3:48