Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


Search this Thread
Old 11-14-2007, 04:16 AM   #1
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, 05:57 AM   #2
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,557

Rep: Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085Reputation: 1085
sed ...
... awk ...
... perl ...

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

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

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
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.

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

Original Poster
Rep: Reputation: 15
Thanksk a lot!


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 09:37 AM
shell script for changing a txt file content Flobsi Linux - Newbie 3 10-06-2006 04:10 AM
how to print txt files into the textview shandy^^^ Programming 1 02-04-2006 04:05 PM
I can only print ps/txt files ? TroelsSmit Linux - Newbie 3 09-12-2004 02:15 PM
changing login words jayakrishnan Linux - General 13 05-16-2003 07:27 PM

All times are GMT -5. The time now is 09:54 AM.

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