We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0a4464f commit ba991a8Copy full SHA for ba991a8
remove_js_comments.sh
@@ -0,0 +1,20 @@
1
+#!/bin/bash
2
+
3
+# Check if a filename is provided
4
+if [ -z "$1" ]; then
5
+ echo "Usage: $0 <filename>"
6
+ exit 1
7
+fi
8
9
+# Check if the file exists
10
+if [ ! -f "$1" ]; then
11
+ echo "Error: File '$1' not found."
12
13
14
15
+# Use awk to remove lines starting with optional whitespace then //
16
+# This does NOT remove comments appearing after code on the same line.
17
+# Note: This creates a temporary file for safety.
18
+awk '!/^[[:space:]]*\/\// {print}' "$1" > "$1.tmp" && mv "$1.tmp" "$1"
19
20
+echo "Removed full-line comments (potentially indented) from '$1'."
0 commit comments