Sponsored Content
Top Forums Shell Programming and Scripting Remove special characters from text file Post 302378345 by pludi on Monday 7th of December 2009 03:57:07 PM
Old 12-07-2009
If I interpret you correctly, you want to remove all characters except A-Z (any case) and 0-9, and preserve any whitespaces, right? If so:
Code:
perl -pe 's/[^A-Za-z0-9\s]//g' trial.txt > output.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove special characters from text using PERL

Hi, I am stuck with a problem here. Suppose i have a variable which is assigned some string containing special charatcers. for eg: $a="abcdef^bbwk#kdbcd@"; I have to remove the special characters using Perl. The text is assigned to the variable implicitly. How to do it? (1 Reply)
Discussion started by: agarwal
1 Replies

2. Shell Programming and Scripting

Adding text to file on certain lines with(special characters)

I need to add "new lines" of text with special characters, to specific lines in the file. There are 3 modifications needed. Been testing 2 here without success. #!/usr/bin/perl use FileHandle; $file=FileHandle->new; $FILENAME="/opt/etc/usr/file.txt"; $file->open ("<$FILENAME") or die... (13 Replies)
Discussion started by: A4ron4perl
13 Replies

3. Solaris

How to remove a directory or file with special characters in Solaris

I finally figured out how to remove a file or directory with special characters in the name. It's kind of rudimentary so I thought I would share it with everyone: find .inum -exec rm -rf {} \; (7 Replies)
Discussion started by: jastanle84
7 Replies

4. Shell Programming and Scripting

Read file and remove special characters or strings

Hello all I am getting data like col1 | col2 | col3 asdafa | asdfasfa | asf*&^sgê 345./ |sdfasd23425^%^&^ | sdfsa23 êsfsfd | sf(* | sdfsasf My requirement is like I have to to read the file and remove all special characters and hex characters ranging form 00-1f from 1st column, remove %"'... (1 Reply)
Discussion started by: vasuarjula
1 Replies

5. Shell Programming and Scripting

remove the special characters and move the file into another server

(5 Replies)
Discussion started by: number10
5 Replies

6. UNIX for Advanced & Expert Users

What my puzzle file!, How to remove special characters ??

My application generate file but it have special characters in these file. I would like to clear special characters by vi editor and not use cat /dev/null > to_file I try to remove characters manually, but I'm can not! root@MyHost /tmp> ls -l puzzle.txt -rw-r--r-- 1 root system ... (5 Replies)
Discussion started by: arm_naja
5 Replies

7. Shell Programming and Scripting

Remove Special Characters Within Text

Hi, I have a "|" delimited file that is exported from a database. There is one column in the file which has description/comments entered by some application user. It has "Control-M" character and "New Line" character in between the text. Hence, when i export the data, this record with the new... (4 Replies)
Discussion started by: tarun.trehan
4 Replies

8. UNIX for Dummies Questions & Answers

How to enter special characters in a text file using vi?

Hi, I need to create a test text file with the special characters \342\200\223 in it and to be able to use sed maybe to delete them I tried doing it using vi by pressing CTRL-V and then typing 342 but it does not work. After pressing CTRL-V and typing 342 it seems to just insert the numbers... (1 Reply)
Discussion started by: newbie_01
1 Replies

9. UNIX for Beginners Questions & Answers

To remove any invisible and special characters from the file(exclude @!#$&*)

Hi Guys, My requirement is to remove any invisible and special characters from the file like control M(carriage return) and alt numerics and it should not replace @#!$% abc|xyz|acd¥£ó adc|123| 12áí Please help on this. Thanks Rakesh (1 Reply)
Discussion started by: rakeshp
1 Replies

10. UNIX for Advanced & Expert Users

To remove any invisible and special characters from the file(exclude @#!$*)

Hi Guys, My requirement is to remove any invisible and special characters from the file like control M(carriage return) and alt numerics and it should not replace @#!$% abc|xyz|acd¥£ó adc|123| 12áí Please help on this. Thanks Rakesh (1 Reply)
Discussion started by: rakeshp
1 Replies
STRIP(1)						    BSD General Commands Manual 						  STRIP(1)

NAME
strip -- discard information from ELF objects SYNOPSIS
strip [-d | -g | -S | --strip-debug] [-h | --help] [--only-keep-debug] [-o outputfile | --output-file=outputfile] [-p | --preserve-dates] [-s | --strip-all] [--strip-unneeded] [-w | --wildcard] [-x | --discard-all] [-I format | --input-target=format] [-K symbol | --keep-symbol=symbol] [-N symbol | --strip-symbol=symbol] [-O format | --output-target=format] [-R sectionname | --remove-section=sectionname] [-V | --version] [-X | --discard-locals] file ... DESCRIPTION
The strip utility is used to discard information from ELF objects. The strip utility supports the following options: -d | -g | -S | --strip-debug Remove debugging symbols only. -h | --help Print a help message and exit. --only-keep-debug Remove all content except that which would be used for debugging. -o outputfile | --output-file=outputfile Write the stripped object to file outputfile. The default behaviour is to modify objects in place. -p | --preserve-dates Preserve the object's access and modification times. -s | --strip-all Remove all symbols. --strip-unneeded Remove all symbols not needed for further relocation processing. -w | --wildcard Use shell-style patterns to name symbols. The following meta-characters are recognized in patterns: ! If this is the first character of the pattern, invert the sense of the pattern match. * Matches any string of characters in a symbol name. ? Matches zero or one character in a symbol name. [ Mark the start of a character class. Remove the special meaning of the next character in the pattern. ] Mark the end of a character class. -x | --discard-all Discard all non-global symbols. -I format | --input-target=format These options are accepted, but are ignored. -K symbol | --keep-symbol=symbol Keep the symbol symbol even if it would otherwise be stripped. This option may be specified multiple times. -N symbol | --strip-symbol=symbol Remove the symbol symbol even if it would otherwise have been kept. This option may be specified multiple times. -O format | --output-target=format Set the output file format to format. For the full list of supported formats, please see the documentation for function elftc_bfd_find_target(3). -R sectionname | --remove-section=sectionname Remove the section named by the argument sectionname. This option may be specified multiple times. -V | --version Print a version identifier and exit. -X | --discard-locals Remove compiler-generated local symbols. DIAGNOSTICS
The strip utility exits 0 on success, and >0 if an error occurs. SEE ALSO
ar(1), elfcopy(1), ld(1), mcs(1), elf(3), elftc_bfd_find_target(3), fnmatch(3) BSD
September 17, 2011 BSD
All times are GMT -4. The time now is 03:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy