Visit Our UNIX and Linux User Community


SED and replacing Txt Bullet


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SED and replacing Txt Bullet
# 1  
Old 07-21-2009
SED and replacing Txt Bullet

Hi Guys,

I'm sure that there is simple solution .. I googled .. it and nothing is coming up ... ( I Tried it as hex 0xE2 no luck )

sed -e 's/•/X/g' data.txt > data1.txt

I'm trying to replace bullet with X
Actually VI editor shows this sign:

But it doesn't work - I'm sure that SED just doesn't understand bullet ...
Any ideas how to make it work.

Thank You

Last edited by NDxiak; 07-21-2009 at 04:48 PM..
# 2  
Old 07-21-2009
Code:
sed 's/\xA5/X/' data1.txt

# 3  
Old 07-21-2009
Code:
xlm22-:Desk admin$ sed 's/\xA5/X/' data1.txt
???????
w?  123456 123456
w?  123456 123456
w?  123456 123456
w?  123456 123456

Thank You, But somehow its not working ...
Its just printing question marks

Last edited by NDxiak; 07-21-2009 at 06:55 PM..
# 4  
Old 07-21-2009
Quote:
Originally Posted by NDxiak
...
Actually VI editor shows this sign:

But it doesn't work - I'm sure that SED just doesn't understand bullet ...

That's right ..., try something different instead:

Code:
awk '{gsub("\x95","X")}1' file

Code:
perl -pe 's/\x95/X/g' file

____
EDIT: The hex code for the bullet is \x95

Last edited by rubin; 07-21-2009 at 09:49 PM.. Reason: xA5 -> x95
# 5  
Old 07-21-2009
Hello,

Thank You, Actually minute before you I was able to get it working using code below, Thx anyways... Smilie

Code:
perl -pi -e 's/\xA5/replace/g' data.txt

question is ... I would like to save it as a script.pl

Code:
#!/usr/bin/perl

perl -pi -e 's/\xA5/replace/g' data.txt

Something like this can't be executed - I guess It needs to be formatted differently ? I would appreciate any tips

Last edited by NDxiak; 07-21-2009 at 07:31 PM..
# 6  
Old 07-21-2009
To keep the code concise ( as is ), in bash or the shell of your preference, you can do ...

Code:
#!/bin/bash

perl -pi -e 's/\xA5/replace/g' data.txt

Or if you want a pure perl script, then every step of that compact code will simply be spelled out in more detail ( a bit longer ), I can post it if you needed.
# 7  
Old 07-22-2009
Quote:
Originally Posted by rubin
To keep the code concise ( as is ), in bash or the shell of your preference, you can do ...

Code:
#!/bin/bash

perl -pi -e 's/\xA5/replace/g' data.txt

Or if you want a pure perl script, then every step of that compact code will simply be spelled out in more detail ( a bit longer ), I can post it if you needed.
I would really appreciate that .. It would be great for future reference.

Thank You very much.

Previous Thread | Next Thread
Test Your Knowledge in Computers #169
Difficulty: Easy
Red Hat, Inc. is an Canadian multinational software company.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux Commands needed for replacing variable number of spaces with a single , in a txt file

Hi I want to read a text file and replace various number of spaces between each string in to a single "," or any other character .Please let me know the command to do so. My input file is a txt file which is the output of a SQL table extract so it contains so many spaces between each column of the... (2 Replies)
Discussion started by: Hari Prasanth
2 Replies

2. Shell Programming and Scripting

Awk, sed, shell all words in INPUT.txt find in column1 of TABLE.txt and replce with column2 in

Hi dears i have text file like this: INPUT.txt 001_1_173 j nuh ]az 001_1_174 j ]esma. nuh ]/.xori . . . and have another text like this TABLE.txt j j nuh word1... (6 Replies)
Discussion started by: alii
6 Replies

3. Shell Programming and Scripting

Replacing .dat.gz to .txt.gz in filename

Hi, I tried below method; mv -v /oracle1/scr/tilki/willsendtilkiNew/VOICE-MO_$nfname.gz \ $(echo /oracle1/scr/tilki/willsendtilkiNew/VOICE-MO_$nfname.gz | tr 'dat' 'txt'); nfame variable has the string "dat" . I need to rename files like below; ASIS: 20140902103700_100319.dat.gz... (8 Replies)
Discussion started by: snr_silencer
8 Replies

4. Shell Programming and Scripting

sed -Replacing file path within .txt file

Hi, I am trying to use sed to replace a file path within all the .lay (.txt) files in a folder. I feel that this should be easy but I can't get it to work no matter what i try. I'm using cygwin. For a .txt file containing the below line I want to replace this file path with a new one. ... (1 Reply)
Discussion started by: carlr
1 Replies

5. Shell Programming and Scripting

sed inside sed for replacing string

My need is : Want to change docBase="/something/something/something" to docBase="/only/this/path/for/all/files" I have some (about 250 files)xml files. In FileOne it contains <Context path="/PPP" displayName="PPP" docBase="/home/me/documents" reloadable="true" crossContext="true">... (1 Reply)
Discussion started by: linuxadmin
1 Replies

6. UNIX for Dummies Questions & Answers

replacing a string with another string in a txt file

Dear all, I have a file like below. I want to replace all the '.' in the 3rd column with 'NA'. I don't know how to do that. Anyone has an iead? Thanks a lot! 8 70003200 21.6206 9 70005700 17.5064 10 70002200 . 11 70005100 19.1001 17 70008000 16.1970 32 70012400 26.3465 33... (9 Replies)
Discussion started by: forevertl
9 Replies

7. Shell Programming and Scripting

sed to cp lines x->y from 1.txt into lines a->b in file2.txt

I have one base file, and multiple target files-- each have uniform line structure so no need to use grep to find things-- can just define sections by line number. My question is quite simple-- can I use sed to copy a defined block of lines (say lines 5-10) from filename1.txt to overwrite an... (3 Replies)
Discussion started by: czar21
3 Replies

8. AIX

Bullet proof of user history activity

Hi, is there a bullet proof of getting the history of all commands entered by a user on a specific server and idealy with the times ? We have several servers. Therefore we can simply logon to one and do RLOGINS to go to others. We always first logon to servers with our personnal login and then... (4 Replies)
Discussion started by: Browser_ice
4 Replies

9. Shell Programming and Scripting

sed to read x.txt and grep from y.txt

How would I write a command(s) to read from a file (list) that looks like this: 29847374384 and grep from a second file (list) that looks like this: 29847374384, jkdfkjdf,3833,ddd:confused: (1 Reply)
Discussion started by: smellylizzard
1 Replies

Featured Tech Videos