LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-14-2007, 03:16 AM   #1
Raakh
Member
 
Registered: May 2007
Posts: 128

Rep: Reputation: 15
changing words in txt files


I want to remove ../servlet and /servlet from about 700 java file. how can i do that
 
Old 11-14-2007, 04:57 AM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
sed ...
... awk ...
... perl ...

Any (supposed) higher level programming language of choice ...

Maybe even java ... dunno, I refuse use it.
 
Old 11-14-2007, 05:22 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by Raakh View Post
I want to remove ../servlet and /servlet from about 700 java file. how can i do that
Did you mean to say "from about 700 java files?"

Are all the files in the same directory or in subdirectories?
If they are scattered in subdirectories, use the "find" command to locate the files.

Are the "../servlet" and "/servlet" on a line by themselves?
if so
sed -i '/\.\.\/servlet/d;/\/servlet/d' javafile
will delete them.

Code:
find ./ -type f -name "*.java" -exec sed -i '/\.\.\/servlet/d;\/servlet/d' '{}' \;
 
Old 11-15-2007, 02:40 AM   #4
Raakh
Member
 
Registered: May 2007
Posts: 128

Original Poster
Rep: Reputation: 15
Thanksk a lot!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
command(s) comparing 3 files and changing capitalization of words (+output) kuser:) Linux - General 4 03-21-2012 08:37 AM
shell script for changing a txt file content Flobsi Linux - Newbie 3 10-06-2006 03:10 AM
how to print txt files into the textview shandy^^^ Programming 1 02-04-2006 03:05 PM
I can only print ps/txt files ? TroelsSmit Linux - Newbie 3 09-12-2004 01:15 PM
changing login words jayakrishnan Linux - General 13 05-16-2003 06:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration