possible to scan a file and remove specific characters?

possible to scan a file and remove specific characters?

Post by Steven G. Kar » Sat, 22 Feb 2003 12:15:33





Quote:> I'm sure this is possible just not sure where to look I'd like to scan a
> file and remove the "^M" that windows adds at the end of every line.

tr -d '\r' file > newfile

--
Steve

 
 
 

possible to scan a file and remove specific characters?

Post by bard » Sat, 22 Feb 2003 13:16:45



> I'm sure this is possible just not sure where to look I'd like to scan a
> file and remove the "^M" that windows adds at the end of every line.

use dos2unix, not sure if its in freebsd standard or you may need to
port install it.

 
 
 

possible to scan a file and remove specific characters?

Post by Michael Sierchi » Sat, 22 Feb 2003 13:56:58




>> I'm sure this is possible just not sure where to look I'd like to scan a
>> file and remove the "^M" that windows adds at the end of every line.

> use dos2unix, not sure if its in freebsd standard or you may need to
> port install it.

Usually all you need to do is cat the file:  % cat a > b.  The stdin/stdout
line discipline will remove the extree chars.

Otherwise you can use 'tr' or 'sed' or any number of tools.

 
 
 

possible to scan a file and remove specific characters?

Post by Steve O'Hara-Smit » Sat, 22 Feb 2003 16:25:03


On Thu, 20 Feb 2003 20:56:58 -0800

MS> Usually all you need to do is cat the file:  % cat a > b.  The
MS> stdin/stdout line discipline will remove the extree chars.

        FALSE!

--
C:>WIN                                      |     Directable Mirrors
The computer obeys and wins.                |A Better Way To Focus The Sun
You lose and Bill collects.                 |  licenses available - see:
                                            |   http://www.sohara.org/

 
 
 

possible to scan a file and remove specific characters?

Post by Jens Schweikhard » Sat, 22 Feb 2003 20:31:24




[removing ^M]
# Usually all you need to do is cat the file:  % cat a > b.  The stdin/stdout
# line discipline will remove the extree chars.

There's no such thing as a line discipline for redirection to a file.
"cat a > b" is exactly the same as "cp a b" concerning file contents.

Regards,

        Jens
--
Jens Schweikhardt  http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)

 
 
 

possible to scan a file and remove specific characters?

Post by Aaron Baughe » Sat, 22 Feb 2003 21:31:43



> Usually all you need to do is cat the file: % cat a > b.  The
> stdin/stdout line discipline will remove the extree chars.

It'd better not!  How's cat supposed to know whether those characters
are 'extree'?  Cat knows nothing about text; it just streams bytes.

Quote:> Otherwise you can use 'tr' or 'sed' or any number of tools.

Or perl:

  perl -pi -e 's/\r\n$/\n/' file1 file2 file3

--
Aaron

 
 
 

possible to scan a file and remove specific characters?

Post by David Bolto » Tue, 25 Feb 2003 12:07:18



> I'm sure this is possible just not sure where to look I'd like to scan a
> file and remove the "^M" that windows adds at the end of every line.

This works on my Linux and Mac boxes, but I haven't tried it on FreeBSD,
so YMMV.  Open the file in vim, and:
        %s/^M/^M/gc

Note, you get the '^M' by typing ctrl-v-m simultaneously.  Works like a
charm for me.

Best regards,
David
--
Never argue with idiots.  They drag you down to their level, then beat you
with experience.
- anonymous

 
 
 

1. How to replace specific characters in filenames on multiple files

I have a number of files that has been moved from an old ext2 partition. Some
of the filenames includes non-printable characters that are not displayed correctly
on newer SuSE 8.1 machines.

Any idea how to make a small shell script the runs through the file tree, renaming
files so that the non-printable characters in the filenames are converted to something different ?.

Thanks in advance.


--

2. How to Setup Modem DialOut

3. In text file, replace character in a specific location

4. urep

5. how to remove only files NOT containg a specific string?

6. WIN TV Cinema Pro card in LINUX

7. removing specific records from a text file

8. Linux Frequently Asked Questions with Answers (Part 2 of 6)

9. Search and output Specific Directories to file by locate and then remove

10. Possible to force ALL files created in a specific directory to include g+w ?

11. how to read a text file and write it into a new file character by character?

12. Removing ^M characters from a DOS text file

13. Remove non printable characters from a file