Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Linux search and replace string command

Posted on 2014-12-13
2
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
Zsolt Pribusz earned 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

721 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