This is actually a little harder than I thought it would be. This assumes the file is strings.txt.
#!/bin/bash
user_input="$1"
# Read strings.txtinput into an array
mapfile -t strings_file < strings.txt"$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" >> string_output.txtoutput_"$user_input"
done
exit 0
Save to: char_edit.sh
Make executable: chmod +x char_edit.sh
Run with: ./char_edit.sh your_file