Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Add script to remove empty lines from a file
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcc1212 committed Mar 1, 2024
1 parent ec9b243 commit c5b12a9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bashExercise/4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if [ $# -eq 0 ]; then
echo "Usage: $0 <filename>"
exit 1
fi

input_file="$1"
output_file="${input_file}.tmp"

sed '/^$/d' "$input_file" > "$output_file"

mv "$output_file" "$input_file"

echo "Empty lines removed from $input_file"

0 comments on commit c5b12a9

Please sign in to comment.