LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-09-2008, 09:22 AM   #1
linux_vidhyarthi
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Rep: Reputation: 0
Error in replacing special chars using awk


I have a file with following data :
a$cd
e%gh
I am trying to replace the special chars with space.
When I execute the following command these chars are replaced :
awk '{gsub(/[\041-\177]/,"b",$0);print $0}' temp.txt

Result:
abcd
ebgh

But when I execute
awk '{gsub(/[\041-\175]/,"b",$0);print $0}' temp.txt

Result:
a$cd
e%gh

these chars are not replaced.Could someone tell me if I am doing any mistake.

Thanks in advance
 
Old 04-09-2008, 12:11 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
I have to investigate the reason of this strange behaviour more in depth, but in the meanwhile why don't use
Code:
gawk '{gsub(/[[:punct:]]/," ",$0); print}' temp.txt
 
Old 04-09-2008, 07:39 PM   #3
linux_vidhyarthi
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks,your solution worked.
If you find the reason for the strange behaviour please let me know.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash, filenames, special chars zomane Programming 3 06-15-2007 04:55 AM
HowTo: special chars (ŰűŐő) in file names ceetrom Linux - Newbie 1 11-03-2006 12:53 PM
Problem with special chars in general smokylux Linux - General 6 05-26-2004 04:46 AM
German umlaute (special chars) in file system steltner Linux - General 5 10-27-2003 02:07 PM
telnet and special chars csDraco_ Slackware 7 05-21-2003 09:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration