#!/bin/bash
user_input="$1"
# Read input into an array
mapfile -t strings_file < "$user_input"
# Iterate and extract numbers
for string in "${strings_file[@]}"; do
number_extract=$(echo "$string" | sed -n 's/.*oo+.*oo+\(.*\)pkp.*/\1/p')
count_digits=${#number_extract}
# Check if the length is greater than 7
if [ "$count_digits" -gt 7 ]; then
string=$(echo "$string" | sed 's/oo/o/2')
fi
# Replace + with :
string=$(echo "$string" | sed 's/+/:/g')
echo "$string" >> output_"$user_input"
done
exit 0
Save to: char_edit.sh
Make executable: chmod +x char_edit.sh
Run with: ./char_edit.sh your_file