This is one of most used command in linux to replace the string in files.
find . -name "*.cpp" | xargs grep -l stringtofind | xargs sed -i s/stringtofind/stringtoreplace/
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts
Monday, August 6, 2007
Wednesday, August 1, 2007
Mangling with fd and /dev/null
When doing the code faced a problem with the SSL Libraries doing error output and want to ignore it. Just got a nice idea from my friend Michael Waters. Here it is.
#include <iostream>
#include <fcntl.h>
using namespace std;
int main(int argc,char *argv[])
{
int devnullfd = open("/dev/null",O_RDWR);
int stderrfd = dup(2);
dup2(devnullfd,2);
cerr << "Am I out?" <<>
dup2(stderrfd,2);
cerr << "Am I In?" <<>
close(devnullfd);
}
svn also has the example in C.
You can download from svn with the command below.
svn checkout http://codeoftheday.googlecode.com/svn/trunk/01Aug2007
Enjoy. Will try to get something out tomorrow.
#include <iostream>
#include <fcntl.h>
using namespace std;
int main(int argc,char *argv[])
{
int devnullfd = open("/dev/null",O_RDWR);
int stderrfd = dup(2);
dup2(devnullfd,2);
cerr << "Am I out?" <<>
dup2(stderrfd,2);
cerr << "Am I In?" <<>
close(devnullfd);
}
svn also has the example in C.
You can download from svn with the command below.
svn checkout http://codeoftheday.googlecode.com/svn/trunk/01Aug2007
Enjoy. Will try to get something out tomorrow.
Subscribe to:
Posts (Atom)