Created
October 14, 2024 07:43
-
-
Save DaWe35/6746408768c66eb57ef29bd160f459d7 to your computer and use it in GitHub Desktop.
SRT to TXT converter (removes lines 1, 2, 4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Input and output files | |
input_file="input.txt" | |
output_file="output.txt" | |
# Initialize line counter | |
line_counter=0 | |
# Remove output file if it exists | |
> "$output_file" | |
# Read the input file line by line | |
while IFS= read -r line | |
do | |
# Increment the line counter | |
line_counter=$((line_counter + 1)) | |
# If line is 3rd in the group, write it to the output file | |
if (( line_counter % 4 == 3 )); then | |
echo "$line" >> "$output_file" | |
fi | |
# Reset the counter after every 4 lines | |
if (( line_counter % 4 == 0 )); then | |
line_counter=0 | |
fi | |
done < "$input_file" | |
echo "Finished processing the file. Output saved in $output_file." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment