Re: replace the string in all the files in the directory



On Wed, 29 Nov 2006 23:43:43 +0100
Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx> wrote:

for f in *.c ; do
cp ${f} ${f}~ && sed -e 's/string/replacement/g' < ${f}~ > ${f}
done


cp is used instead of mv, to keep the owner and access rights of ${f}.

&& is used to avoid overwritting the original file if the copy
didn't complete successfully.

Usually, you don't substitute strings, but tokens or words; read
man sed and man 7 regex and use \<word\> in the regexp!

I think he wanted to replace a string such as

"I'm a C literal string!"

to something else. So sed probably won't work for him, as a string may
span through several lines.
.



Relevant Pages

  • Re: API Help please - How do I find the owner of a file or folder using
    ... > I am trying to find the owner of a file or folder on our network (Windows ... > ByVal name As String, cbName As Long, ByVal ReferencedDomainName As ... > Dim ownerName As String ' Name of the file owner ... > ' Retrieve the name of the account and the name of the first domain on ...
    (microsoft.public.dotnet.languages.vb)
  • Re: [Help] At wits end about zOrder and API
    ... as the owner of Windowand Windowas the owner of your userform? ... > (ByVal lpClassName As String, ... > Dim hWndFocus As Long ... > 'Create a string buffer to hold the owner's caption ...
    (microsoft.public.vb.winapi)
  • Re: API Help please - How do I find the owner of a file or folder using
    ... The other thing that threw me is in VB if ByVal or ByRef is not specified ... the owner ... >> to GetFileSecurityfails to assign the buffer size to sizeSD so it ... >> ByVal name As String, cbName As Long, ByVal ReferencedDomainName As ...
    (microsoft.public.dotnet.languages.vb)
  • API Help please - How do I find the owner of a file or folder using
    ... I am trying to find the owner of a file or folder on our network (Windows ... Private Declare Function GetSecurityDescriptorOwner Lib "advapi32.dll" _ ... ByVal name As String, cbName As Long, ByVal ReferencedDomainName As ... If bSuccess = 0 Then Exit Function ...
    (microsoft.public.dotnet.framework.interop)
  • RE: File owner attributes through Excel VBA
    ... I found an easier way of getting the file owner without having to use a DLL. ... Dim Folder As String ... the ownship through VBA since VBA can call any application. ...
    (microsoft.public.excel.programming)