Skip to content

Commit

Permalink
SnapShot
Browse files Browse the repository at this point in the history
  • Loading branch information
DataEraserC committed Feb 3, 2024
1 parent 8b0f5ca commit 115a9d9
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions scripts/fix-shebang.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os

def traverse_files(directory):
for root, dirs, files in os.walk(directory):
for file_name in files:
if file_name.endswith(".sh"): # Only operate on files with .sh extension
file_path = os.path.join(root, file_name)
with open(file_path, "r") as file:
file_content = file.read()

# Replace strings
replacement = "/usr/bin/env "
file_content = file_content.replace("/usr/bin/env ", "<placeholder>")
file_content = file_content.replace("/usr/bin/", replacement)
file_content = file_content.replace("<placeholder>", "/usr/bin/env ")

with open(file_path, "w") as file:
file.write(file_content)

print("File", file_name, "has been updated!")

print("Batch replace completed!")

# Get the current directory
current_dir = os.getcwd()

# Traverse files in the current directory
traverse_files(current_dir)

0 comments on commit 115a9d9

Please sign in to comment.