Solved

Linux search and replace string command

Posted on 2014-12-13
2
256 Views
Last Modified: 2014-12-13
I found this Linux command on the web to search and replace a string in files.  What does + do at the end of this command?

find . -type f  -exec sed -i 's/foo/bar/' {} +
0
Comment
Question by:rudy201
2 Comments
 
LVL 4

Accepted Solution

by:
Zsolt Pribusz earned 500 total points
ID: 40497844
Here is a part from find manual:

       -exec command {} +
            This  variant  of the -exec option runs the specified command on
            the selected files, but the command line is built       by  appending
            each  selected file name at the end; the total number of invoca-
            tions of the command will       be  much  less       than  the  number  of
            matched  files.      The command line is built in much the same way
            that xargs builds its command lines.  Only one instance of  '{}'
            is  allowed  within the command.      The command is executed in the
            starting directory.

Link to find man page:
http://unixhelp.ed.ac.uk/CGI/man-cgi?find
Link to stream editor (sed) man page:
http://unixhelp.ed.ac.uk/CGI/man-cgi?sed
0
 
LVL 23

Expert Comment

by:savone
ID: 40497852
Try this:

find . -type f  -exec sed -i 's/foo/bar/' {} /;
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question