how to remove all unneeded characters from a .txt file?(only keep letters and numbers)

Status
Not open for further replies.

aznricepuff

Honorable
Oct 17, 2013
38
0
10,610
If you are under windows, install cygwin: https://www.cygwin.com/

Then open up the cygwin terminal and use the following command:

Code:
for f in *.txt; do sed 's/[^[:alnum:]]//g' "$f"; done

This loops through all files with a .txt extension in the current directory and deletes all non-alphanumeric characters. If you want to preserve whitespace as well:

Code:
for f in *.txt; do sed 's/[^[:alnum:][:space:]]//g' "$f"; done
 
Status
Not open for further replies.