removing non-printable chars from multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing non-printable chars from multiple files
# 1  
Old 01-19-2009
removing non-printable chars from multiple files

How do I remove non-printable characters from all txt files and output the results to one file?

I've tried the following:
Code:
tr -cd '[:print:]\n' < *.txt > out.txt

and it gives ambiguous redirect error.

How can I get it to operate on all txt files in the current directory and append the output to out.txt?
# 2  
Old 01-19-2009
Try this:
Code:
ls -1 | while read FNAME; do tr -d '[:cntrl:]' < "${FNAME}" > "${FNAME}".out; done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Stripping of Non-Printable Chars in the Who Is Online Page

Noticed that after changing our site and HTML be to UTF-8 compliant per HTML5 standards, we started to see unprintable chars in the country and city name from the geoip database which converts IP addresses to country and city names. So, I just added this code to that PHP plugin which seems to do... (1 Reply)
Discussion started by: Neo
1 Replies

2. Shell Programming and Scripting

Removing a ? from multiple files

Hi all, I have about 1.8 million files in a directory structre, that contain a ? on the end, for example: /testdocs/1/mar/08/08/images/user/{1234-1234-1234-1234}0? Is there a way to go through the testdocs folder, recursively, and remove the ? from all docs that have one on the end? ... (11 Replies)
Discussion started by: tirmUK
11 Replies

3. UNIX for Beginners Questions & Answers

Change encoding, no removing special chars. inconv

Hi all, I'm using iconv command to change files encoding to UTF-8 If my input file has chars as those are removed creating the file without those special chars. I tried using iconv -c, but there is still the removal. Is there a way to keep those special chars changing just the... (6 Replies)
Discussion started by: mrreds
6 Replies

4. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies

5. Shell Programming and Scripting

Rename and add chars to multiple files at once

i have a little over 100 files named page1.jpg through page106.jpg. How can I rename them all to remove the page word and add 00 in front of the remaining numbers? I realize this might be multiple commands but cp page*.jpg *.jpg didn't work like I thought it would. (4 Replies)
Discussion started by: zimmerru
4 Replies

6. Shell Programming and Scripting

Removing rows and chars from text file

Dear community, maybe I'm asking the moon :rolleyes:, but I'm scratching my head to find a solution for it. :wall: I have a file called query.out (coming from Oracle query), the file is like this: ADDR TOTAL -------------------- ---------- TGROUPAGGR... (16 Replies)
Discussion started by: Lord Spectre
16 Replies

7. Shell Programming and Scripting

Removing unknow chars from file names.

I'm trying to move a large folder to an external drive but some files have these weird chars that the external drive won't accept. Does anyone know any command of any bash script that will look through a given folder and remove any weird chars? (4 Replies)
Discussion started by: Joktaa
4 Replies

8. UNIX for Dummies Questions & Answers

removing non printable characters

Hi, in a file, i have records as below: 123|62|absnb|267629 123|267|28728|uiuip 123|567|26761|2676 i want to remove the non printable characters after the end of each record. I guess there are certain charcters but not visible. i don't know what character that is exactly. I used... (2 Replies)
Discussion started by: pandeesh
2 Replies

9. Shell Programming and Scripting

Removing Non-printable characters in unix file

Hi, We have a non printable character "®" in our file , we want to remove this character, we tried tr -dc '' < oldfile> newfile but this command is removing all new line entries along with the non printable character and all the records are coming in one line(it is changing the format of the... (2 Replies)
Discussion started by: pyaranoid
2 Replies

10. Shell Programming and Scripting

Removing M^ from multiple files

to do this i usually type dos2unix <file> -o <file> and this will remove the M^ from the end of each file. well i have over 100 files that someone copied that i need. how do i remove the M^. i saw a perl script but i am not familiar with .pl at all really (7 Replies)
Discussion started by: deaconf19
7 Replies
Login or Register to Ask a Question