I'm currently taking a crash course in the basics of the Linux terminal and one of the tasks is to replace punctuation in a text file using 'awk' and 'tr' commands. I have tried searching around for solutions but nothing is working for me, any help?
Using tr
(as Glenn Jackman has already pointed out):
cat TEXTFILE | tr -d '[:punct:]' > OUTFILE
Using awk
(tested with gawk
and mawk
):
cat TEXTFILE | awk '{ gsub(/[[:punct:]]/, "", $0) } 1;' > OUTFILE
You can also omit cat
with AWK:
awk '{ gsub(/[[:punct:]]/, "", $0) } 1;' TEXTFILE > OUTFILE
Note: TEXTFILE and OUTFILE must be different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With