Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

remove ??? in file, pls help ...

Status
Not open for further replies.

hendnov

Technical User
Feb 27, 2006
73
AU
Hi guys, just wondering about simple question.

I want to remove ??? in some of files. what I did is :

Code:
cp awi.xml awi.xml_tmp
cat awi.xml_tmp | sed s/???// > awi.xml

Is there any way to make it one way without copying to awi.xml_tmp first ?

coz I tried :

Code:
cat awi.xml | sed s/???// > awi.xml

the result it is the file awi.xml is blank :((

any idea guys ??
 
And what about this ?
echo ",s/???//g\nw\nq" | ed -s awi.xml

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

Thanks for your reply, but

It didnt change anything yet :(
Here's what happened
Code:
adoc syducmp02 ~> echo ",s/???//g\nw\nq" | ed -s test
?
adoc syducmp02 ~>

and I checked test file, it doesn't change anything.

 
See your ed man page, perhaps the -s option is not available, i'd try it without that -s flag


HTH,

p5wizard
 
Hi,

try rhis code
Code:
ex /path/to/yourfile 1>/dev/null 2>&1 <<- !EOEX
       1,$ s/???//g
       wq
!EOEX

include this code in a loop for other files
 
And this ?
echo "1,\$s/???//g\nw\nq" | ed -s test

Or this ?
/bin/echo echo "1,\$s/???//g\nw\nq" | ed -s test

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You should read the questions more carefully mrn, he wants to edit the file in place.

Annihilannic.
 
No he said he didn't want to copy it first, which is different to not creating a copy at all.

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Fair enough. I presume by "one way" though he meant in one step; using your method he would still have to copy awi.new back to awi.xml.

Annihilannic.
 
Hmmm I suppose you could be correct, but that's not how I read it. ok what about

sed s/???// < awi.xml > awi.new && mv awi.new awi.xml

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Perhaps he wants to edit the file in place because some other process already has the file open and that process would need to be restarted otherwise? Just guessing...


HTH,

p5wizard
 
Hi Guys,

Thx for the input, yeah p5wizard is right.

I want to edit the file in place because this file is part of my application file. If I change it or copy it to another file first, I have to stop and restart the application. That's what I did in my staging server but in my production server which is online and has 4000 viewers, I can't just stop and restart the server.

That's all guys,

but I'll try mrn ways this morning, btw where are you guys from ??? I'm in Sydney ;p. Just wanna know you guys more. Coz you guys helped me alot. THX
 
Is the file being written to be the app? If it is I wouldn't mv the file.

UK - btw

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
You didn't answer Annihilannic do you have the -i option?

Mike

"A foolproof method for sculpting an elephant: first, get a huge block of marble, then you chip away everything that doesn't look like an elephant."

 
Sorry guys,

I respond a little bit late, yeah my server didn't have sed -i option :(( ?

Thx

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top