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

aznricepuff

Honorable
Oct 17, 2013
38
0
10,610
12
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
 
Thread starter Similar threads Forum Replies Date
M Apps General Discussion 2
M Apps General Discussion 0
omar muzzammil Apps General Discussion 2
B Apps General Discussion 1
T Apps General Discussion 1
A Apps General Discussion 3
M Apps General Discussion 1
A Apps General Discussion 7
B Apps General Discussion 2
B Apps General Discussion 1
H Apps General Discussion 1
C Apps General Discussion 2
P Apps General Discussion 5
B Apps General Discussion 2
P Apps General Discussion 1
A Apps General Discussion 4
P Apps General Discussion 3
I Apps General Discussion 3
W Apps General Discussion 3
T Apps General Discussion 3

ASK THE COMMUNITY