LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-15-2009, 11:24 AM   #1
tomerbd
LQ Newbie
 
Registered: Sep 2003
Posts: 11

Rep: Reputation: 0
sed updated/touched also files that i didnt search replace in them


Hi
I performed:

Code:
find . -name '*.java' -type f -exec sed -i 's/searchforthis/replaceiwththis' {} \;
and also files that did not have the searchforthis where like touched so the svn wanted me to check them in which resulted in svn asking me to commit all my .java files... is there a way to let the sed touch only files that had the orig pattern searchforthis? or maybe i did something wrong?
 
Old 10-15-2009, 11:28 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
I would not say you did anything **wrong**, but it was not something I would recommend.

First, don't use sed -i without also specifying a backup AND also being totally sure that you have the right SED syntax.

Second, be sure you know what files that find is going to find---e.g. keep in mind that it is going to go into subdirectories by default.
 
Old 10-15-2009, 06:57 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,226

Rep: Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023Reputation: 2023
The point is that sed has to read the files in order to find out if the search string is in there or not. You need to get svn to check mtime, not atime, if that's possible.
 
  


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
sed - multiline search/replace with wildcard troubles Yalla-One Programming 4 12-29-2008 12:01 PM
sed search replace tomerbd1 Linux - General 9 04-10-2008 04:31 AM
sed question for search and replace jakev383 Linux - General 8 05-05-2007 05:40 AM
Bit complicated sed search & replace sharathkv25 Programming 6 04-07-2007 01:53 PM
sed search & replace sharathkv25 Programming 2 03-07-2007 10:16 AM


All times are GMT -5. The time now is 11:46 AM.

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