Visit Our UNIX and Linux User Community

Full Discussion: Replace Junk chars (Sed)
Top Forums Shell Programming and Scripting Replace Junk chars (Sed) Post 302111300 by Deal_NoDeal on Tuesday 20th of March 2007 04:12:53 PM
Old 03-20-2007
Originally Posted by alfredo123
I know this has been asked previously on this forum...But I think I have a different scenario to present.

I ahve a file tht looks like this (note:there are control Z and other chars tht are not visible on line with anme bowers)

BB7118450      	6004718		BIANCALANA =HEI         
BZ5842819      	1493750		ZACHAR=/                
AB1250620      	0300080		BOWERS               
MR0408256      	0458355		DYCUS/BOWERS/PA         
AB9381233      	6811741		BOWERS *6*              
BL6039588      	0184195		LIMERES JR. |           
AD1901253      	0458720		DURAZO - CELAYA         
BE4340698      	0609541		EL-HAJJAOUI(LUN         
AH5528267      	6786292		HARSANY, JR ++          
BD0762662      	4527818		D`SOUZA                 
AC6629577      	3059914		CANOVA`                 
AC9130991      	0485282		CARROLL 16!            
AT8874679      	0490912		TAIT 20!               
AH8136459      	0136813		HUNTER 06! (16

This file has special chars and Control M/Z chars....I need to remove all these junk chars and replace with a space. I tried the following commands..

sed 's/[!@#\$%^&*()<>+|={}\/`-]//g' special.txt

The above worked except for the fact that the Control Z chars were not replaced.

I tried
tr -d '\032' < special.txt | sed 's/[!@#\$%^&*()<>+|={}\/`\"\^M\'026'-]//g' > t

but some additional chars were deleted...

Any help in getting the command right would be appreciated...
Try to use

tr -d "\015\032" < inputfile > outputfile

Then use your sed on the outputfile. Let me know if this works.
Test Your Knowledge in Computers #493
Difficulty: Medium
When a program executes, each command executes one after the other, top-to-bottom. This is known as inconsequential control flow.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace ascii chars without loosing it.

Hi, Can some one tell, how to replace ascii non printable TAB from the while to something, then later on replace it back to TAB. Basciallz we do bulk data processing, our processin treats TAB as new field , So I thought we can replace it with something and later on revert it. TIA (4 Replies)
Discussion started by: braindrain
4 Replies

2. Shell Programming and Scripting

Clense Junk Data File - Using Shell or awk or sed

Hello Shell Gurus i need help in solving this puzzle. We have a junk data file that needs to be fed into the database. Need to clense the data file thru shell script. I am not a expert and so need help with Here is what i need to do on the input file -Step -1 Replace all pipes |' within... (1 Reply)
Discussion started by: rimss
1 Replies

3. Shell Programming and Scripting

replace chars,

:rolleyes: Hi, I want to replace the particular text in the middle of the line. Ex. In the line 40-50 wanted to replace the char as 'x' (7 Replies)
Discussion started by: Jairaj
7 Replies

4. UNIX for Dummies Questions & Answers

Using SED to get n chars after given value from file

Hello, my name is Marc, I'm a linux starter :) and I hope you specialists can help me solving this issue. I have a file containing a lot of data. Somewhere in this file, there's a string called "Faultdump", directly followed by 64 chars of HEX data. I need to get the HEX part. I accomplished... (12 Replies)
Discussion started by: Kally
12 Replies

5. Shell Programming and Scripting

is is possible remove junk chars from the strings?

Hello friendz, dfl;g435hkd.fg ..this is what I am getting. I want to print strings without junk chars. I want to exactly like this... dflg435hkd.fg ...need some specific operators also. for example, dot or comma should allow. plz help me out ya! ~Balan:confused: (1 Reply)
Discussion started by: balan_mca
1 Replies

6. Shell Programming and Scripting

sed discard chars after last _

Hi, I'd get fields like unix_linux_form_yyyyddmmhhmi.file.txt shell_programming_and_scripting.txt so on... and want them as below unix_linux_form shell_programming_and I could remove everything after a '.' as below echo $field | sed 's/\..*//' but how to remove... (14 Replies)
Discussion started by: dips_ag
14 Replies

7. Shell Programming and Scripting

How to erase junk Chars coming in only the first line

I have a file containing few thousands of lines. when I do cat on it , i find it having two special Chars at the start of first line alone as shown down here. HDR|20111024|01 If i delete this line and do a cat on file , the current first line is shown to have the same special Chars. ... (3 Replies)
Discussion started by: subramanian2008
3 Replies

8. Shell Programming and Scripting

Replace char between chars - help needed

Hello, I have a csv file with "^" as text delimiters and "|" as field delimiters. It's converted from a xls file. One record looks like this: ^Tablete Internet^|Archos|501838|^Tableta Internet ARCHOS 80 G9 ...| ... (more lines) ... "501|838"^|330.00|USD|sl|12|0|Link|^router wireless 150... (10 Replies)
Discussion started by: go0ogl3
10 Replies

9. UNIX for Dummies Questions & Answers

Grep or sed to search, replace/insert chars!

HI All Im trying to come up with an approach to finding a string, using a portion of that string to insert it on lines starting with the value "GOTO" appending to end of line after removing PT's ( See example below! ) EXAMPLE: 1. I would like to search for the line that starts with "TLAXIS/"... (7 Replies)
Discussion started by: graymj
7 Replies

10. UNIX for Dummies Questions & Answers

How to replace and remove few junk characters from a specific field?

I would like to remove all characters starting with "%" and ending with ")" in the 4th field - please help!! 1412007819.864 /device/services/heartbeatxx 204 0.547%!i(int=0) 0.434 0.112 1412007819.866 /device/services/heartbeatxx 204 0.547%!i(int=1) 0.423 0.123... (10 Replies)
Discussion started by: snemuk14
10 Replies
Perl(3pm)						User Contributed Perl Documentation						 Perl(3pm)

Term::Size::Perl - Perl extension for retrieving terminal size (Perl version) SYNOPSIS
use Term::Size::Perl; ($columns, $rows) = Term::Size::Perl::chars *STDOUT{IO}; ($x, $y) = Term::Size::Perl::pixels; DESCRIPTION
Yet another implementation of "Term::Size". Now in pure Perl, with the exception of a C probe run on build time. FUNCTIONS chars ($columns, $rows) = chars($h); $columns = chars($h); "chars" returns the terminal size in units of characters corresponding to the given filehandle $h. If the argument is omitted, *STDIN{IO} is used. In scalar context, it returns the terminal width. pixels ($x, $y) = pixels($h); $x = pixels($h); "pixels" returns the terminal size in units of pixels corresponding to the given filehandle $h. If the argument is omitted, *STDIN{IO} is used. In scalar context, it returns the terminal width. Many systems with character-only terminals will return "(0, 0)". SEE ALSO
It all began with Term::Size by Tim Goodwin. You may want to have a look at: Term::Size Term::Size::Unix Term::Size::Win32 Term::Size::ReadKey It would be helpful if you send me the generated by the probe at build time. Please reports bugs via CPAN RT, BUGS
I am having some hard time to make tests run correctly under the "cpan" script. Some Unix systems do not seem to provide a working tty inside automatic installers. I think it needs some skip tests, but I am yet not sure what should be the portable tests for this. Update: This distribution uses new tests to skip if filehandle is not a tty. It was noticed that "Test::Harness" and "prove", for instance, provide a non-tty STDOUT to the test script and automatic installers could provide a non-tty STDIN. So the former tests were basically wrong. I am improving my understanding of the involved issues and I hope to soon fix the tests for all of Term::Size modules. AUTHOR
Copyright (C) 2006-2007 by A. R. Ferreira This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-22 Perl(3pm)

Featured Tech Videos

All times are GMT -4. The time now is 01:17 PM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy