The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
delete blank space in begining of line karthikn7974 Shell Programming and Scripting 4 05-07-2008 04:40 AM
append blank space HAA Shell Programming and Scripting 1 09-03-2007 04:43 AM
Replace blank spaces by single tab, and right alignment Jae Shell Programming and Scripting 1 08-08-2007 10:58 PM
how to grep for blank records (space,tab,/n)? Browser_ice UNIX for Dummies Questions & Answers 2 08-14-2006 10:47 PM
check for the first character to be blank anthreedhr UNIX for Dummies Questions & Answers 7 10-22-2003 10:05 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-14-2008
rollthecoin rollthecoin is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 26
How can i replace a character with blank space?

i want a command for my script!!!

say file consists of character 123 125 127.

i need a query to replace the number 2 with 0

so the output should be 103 105 107.

i use unix-aix
  #2 (permalink)  
Old 04-14-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Code:
tr -s '2'  '0' < oldfile > newfile
  #3 (permalink)  
Old 04-14-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
Quote:
Originally Posted by rollthecoin View Post
say file consists of character 123 125 127.
I am not sure about what you mean: ist this the text as it is in your file or are these decimal (octal?) values for three characters in your file?

If this is text you can use the following:

Code:
sed 's/12\([0-9]\)/10\1/g' /path/to/file > /path/to/other/file
I hope this helps.

bakunin
  #4 (permalink)  
Old 04-16-2008
rollthecoin rollthecoin is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 26
No.

I will tell you clearly.

i want to delete a invalid character(which i told you as example '2'.)

The query should check for characters which is not present in the following
A to Z,
a to z ,
0 to 9
and all the symbols present in the keyboard.

If you have any doubts reply me.

Last edited by rollthecoin; 04-16-2008 at 05:34 AM..
  #5 (permalink)  
Old 04-17-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
Quote:
Originally Posted by rollthecoin View Post
The query should check for characters which is not present in the following
A to Z,
a to z ,
0 to 9
You have already solved the problem almost - all on your own. Just construct a simple regular expression from your goal:

Code:
[^A-Za-z0-9.,#&@]
will find any characters which are not small characters, capitalized characters, digits or some punctuation characters. Add in the brackets more punctuation characters to exclude them too from the found characters as per your request. Now put this mechanism to work with "sed" or whatever:

Code:
sed '/[^A-Za-z0-9.,#&@]//g' /path/to/sourcefile > /path/to/newfile
will delete all the characters not covered in the regexp and write the result to a file. Check this file and modify the regexp as necessary depending on the result.

I hope this helps.

bakunin
  #6 (permalink)  
Old 04-18-2008
rollthecoin rollthecoin is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 26
Myscript

#!/usr/bin/ksh
sed '/[^A-Za-z0-9.,#&@]//g' /home/1.txt > /home/2.txt


it throws error like this
"sed: 0602-403 /[^A-Za-z0-9.,#&@]//g is not a recognized function."


why is it so.
did i do any mistake?

Last edited by rollthecoin; 04-18-2008 at 03:40 AM..
  #7 (permalink)  
Old 04-18-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
My bad, i had a typo in the script:

Code:
sed '/[^A-Za-z0-9.,#&@]//g' /path/to/sourcefile > /path/to/newfile
should be

Code:
sed 's/[^A-Za-z0-9.,#&@]//g' /path/to/sourcefile > /path/to/newfile
bakunin
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0