A number of my projects standardize on 80 characters per line. I have tried to use Process Lines to simplify this process:
1) Text > Process Lines Containing...
2) Check the Grep checkbox
3) Use the following pattern to target all lines with 80 or more characters:
.{{0,79}}
I've done it enough times that it would be useful to have this run as a filter so that I don't need to invoke it manually each time. However, a (admittedly shitty) first pass with ChatGPT to wrap these steps in a script returns a different result.
An example script is shown below.
#!/bin/bash
# Read input line by line
while IFS= read -r line; do
# Delete characters longer than 80 characters
modified_line=$(echo "$line" | sed -E 's/.{81,}//g')
echo "$modified_line"
done
Is GPT just dumb or am I missing something obvious?