Taken with Instagram at Presernov trg
Taken with Instagram at Ljubljana
This snippet is short and helpful, though not a simple one and in cases even a dangerous one. It will help you replace text in multiple files on a Mac or Linux through a terminal.
Warning: make sure you know what you’re doing! I take NO responsibility for any damage caused by running the commands explained below!
find A_FOLDER -name '*.SOME_FILE_EXTENSION'|sed 's/ /\\ /g'|xargs perl -pi -e 's/FIND_THIS_TEXT/REPLACE_WITH_THIS_TEXT/g'
The placeholders I’ve put in the command are self-explanatory, but I’ll describe them anyway.
The folder where the search will start. It can be the current one (.), just try to make sure that you DO NOT RUN this in the root (/).
Search only for this specified extension. To search through all filetypes, you can just omit the whole “-name” argument.
The text your searching for.
The replacement text.
The breakdown of the command, just to make it easier for you to understand what we just did there:
- find A_FOLDER -name ‘*.SOME_FILE_EXTENSION’
Tries to find all specified files within the specified location (and its children).
- sed ‘s/ /\ /g’
The previous command does not escape the spaces in the paths, so we correct that here.
- xargs perl -pi -e ‘s/FIND_THIS_TEXT/REPLACE_WITH_THIS_TEXT/g’
Then the correct output is sent to the perl interpreter to do its magic and make the replacement itself.
For example, I’d replace my old company name in the header text of all source files (.m) belonging to a project named “foobar” by running the following:
find /Users/bojand/Projects/foobar -name '*.m'|sed 's/ /\\ /g'|xargs perl -pi -e 's/MyOldCompany/MyNewCompany/g'
A Cold January Night (Taken with Instagram at Ljubljana)
One rainy afternoon (Taken with instagram at Ljubljana)
Gorgeous Ljubljana (Taken with instagram)
RT @thurrott: Shhh…. It’s true: Microsoft is working on iPad apps.
When trying to install Rails 3.0 on a fresh Ruby 1.8.7 setup on your Mac, you may get this error:
Exception `Errno::ENOENT' at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rdoc/options.rb:576 - No such file or directory - lib
File not found: lib
I’ve resolved the issue by installing rdoc and followed the instructions given by the install process:
$ sudo gem install rdoc
$ sudo gem install rdoc-data
$ sudo rdoc-data --install
$ sudo gem rdoc --all --overwrite
When trying to access a Subversionrepository with SSH using the Subversion command-line tool on Windows (svn.exe), the following error occurs:
svn: Can't create tunnel: The system cannot find the file specified.
The solution is quite simple, indeed. The only additional software needed is PuTTY (http://bit.ly/PjvGj).
Make sure your key is loaded with Pageant.
Set the SVN+SSH environment variable:
- Tip: You can access the System panel by pressing Windows Key + Break
- Windows XP: Control Panel > System > Advanced > Environment Variables > System Variables > New…
Windows Vista/7: Control Panel > System > Advanced System Settings > Environment Variables > System Variables > New…
- Variable name: SVN_SSH
- Variable value: C:\Program Files\PuTTY\plink.exe (If the path to PuTTY is different from the one above, change it accordingly, but make sure that all backslashes are doubled)
Open a new (!) command-line and try listing one of your repositories. It would look something like this:
svn list svn+ssh://firstname.lastname@example.org/svn/foo/bar
Another approach is to use TortoiseSVN’s plink, which works well with the Subclipse plug-in for Eclipse.