|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
tr -s '2' '0' < oldfile > newfile |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
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
|
|||
|
|||
|
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.. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Quote:
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 |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
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.. |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
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 |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Replace colon with blank space | chumsky | UNIX for Dummies Questions & Answers | 2 | 11-24-2011 02:44 AM |
| Replace comma with a blank space using SED | jayT | Shell Programming and Scripting | 5 | 01-21-2011 09:42 AM |
| how to replace a character with blank in a file | sridhusha | Shell Programming and Scripting | 4 | 02-02-2010 08:08 AM |
| Replace a blank space with string "\\ " | Akshay4u | Shell Programming and Scripting | 7 | 02-06-2009 04:10 PM |
| How to replace all entries of comma in text file by space or other character | prashant43 | Shell Programming and Scripting | 4 | 08-30-2008 12:53 AM |
|
|