LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 10: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, 01:11 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
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, 08: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:55 AM
HowTo: special chars (ŰűŐő) in file names ceetrom Linux - Newbie 1 11-03-2006 01:53 PM
Problem with special chars in general smokylux Linux - General 6 05-26-2004 05:46 AM
German umlaute (special chars) in file system steltner Linux - General 5 10-27-2003 03:07 PM
telnet and special chars csDraco_ Slackware 7 05-21-2003 10:57 AM

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

All times are GMT -5. The time now is 04:05 PM.

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