Computing.Net > Forums > Linux > Command to find files and update

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Command to find files and update

Reply to Message Icon

Name: GigabitTech
Date: December 26, 2007 at 20:30:49 Pacific
OS: Linux (CentOS)
CPU/Ram: Pentium-3 1GB
Product: Intel
Comment:

I'm a new-be in Linux
I want to be able to update/overwrite all files named 'test.txt' in a directory(and its subdirectory) with a particular text, say 'information'.
The files named test must be searched recursively within the directory as they may be present in any of the sub-directories.

Would be glad if anyone tell me a command for this.

Thanks and Regards




Sponsored Link
Ads by Google

Response Number 1
Name: jefro
Date: December 27, 2007 at 12:17:03 Pacific
Reply:

There is not one command. You would need to use various commands either in a script(batch file) or on a single line that takes the output from one function to the input of the next.

There are many ways to do it. They all would involve some form of what you asked it to do.

Search files by name, recursive. (some people put files listed in a new file to use as second part of input)
Take those files and search for text string.
Replace string with new string..

See the man pages on functions and put together a plan. I think you can do it.

I read it wrong and answer it wrong too. So get off my case you peanut.


0

Response Number 2
Name: nails
Date: December 28, 2007 at 14:51:30 Pacific
Reply:

This "gres" link might give you a place to start:

http://www.computing.net/unix/wwwbo...


0

Response Number 3
Name: Luke Chi
Date: February 7, 2008 at 15:04:10 Pacific
Reply:

find . -name test.txt | while read FILENAME do
echo information > $FILENAME
done

Luke Chi


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Please help me! Drivers in Gutsy



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Command to find files and update

What is command to find shell? www.computing.net/answers/linux/what-is-command-to-find-shell/12486.html

Need to find binary and script file www.computing.net/answers/linux/need-to-find-binary-and-script-file/25370.html

Command to find directory www.computing.net/answers/linux/command-to-find-directory/19019.html