By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

Delete a line from the fil

100+
P: 123
hi all

i have a directory in which there are numbers of files.
Each file contains the following code at the end

Expand|Select|Wrap|Line Numbers
  1.  
  2. <p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close()" /></p>
  3.  
i want to remove that code from all the files in the directory

I have tried out

Expand|Select|Wrap|Line Numbers
  1.  perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close()" \/><\/p> /           /gi'  .*php 
  2.  
but it's not working..is there any other way to do so..
I have tried out sed command also
sed 'N;$;$;$d' filename but still not working..
Apr 28 '08 #1
Share this Question
Share on Google+
2 Replies


KevinADC
Expert 2.5K+
P: 4,059
hi all

i have a directory in which there are numbers of files.
Each file contains the following code at the end

[code ]
<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close()" /></p>
[/code]

i want to remove that code from all the files in the directory

I have tried out

Expand|Select|Wrap|Line Numbers
  1.  perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close()" \/><\/p> /           /gi'  .*php 
  2.  
but it's not working..is there any other way to do so..
I have tried out sed command also
sed 'N;$;$;$d' filename but still not working..

Try:

Expand|Select|Wrap|Line Numbers
  1.  perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close\(\)" \/><\/p> /           /gi'  .*php 
  2.  
The parenthesis should be escaped \(\) otherwise perl will see them as capturing brackets and not literal parenthesis. I'm not sure if perl expands .*php into a list of files to edit. Hopefully it does.
Apr 28 '08 #2

100+
P: 123
Try:

Expand|Select|Wrap|Line Numbers
  1.  perl -pi -e 's/<p align="right"><input name="closeme" type="button" value="Close Window" onclick="self.close\(\)" \/><\/p> /           /gi'  .*php 
  2.  
The parenthesis should be escaped \(\) otherwise perl will see them as capturing brackets and not literal parenthesis. I'm not sure if perl expands .*php into a list of files to edit. Hopefully it does.

Thanks Kevin..
IT's working
Apr 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.