LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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: 12,224

Rep: Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019Reputation: 1019
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
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 08:32 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration