The fine fine art of command line programming keeps suprising me, it’s brilliant what you can acomplish with a few lines of commands all mixed up in grep and other linux commands. Continue reading
Category Archives: Linux
cleaning up after svn
when you want to move a project from one svn repo to another, or just want the svn removed from your drive you can use find . -name “.svn“ -exec rm -rf {} \; to do so. Just remember to place yourself in the correct folder.
Posted in Linux, Rock n Roll
yet a nother small find command
while working on optimizing blog.politiken.dk I constantly find myself snooping around for certain functions within the belly of wordpress mu, figuring out where these functions are located can be difficult, especially since the former consultant didn’t spend much time documenting their work.
Being able to find a certain function fast is helpfull and since thats basically the only way to go…
By now I’ve optimized my grep’s several times and in constantly optimizing these I’ve come up with this one: find . -name “*.php” | xargs grep -in “customer”
It’s almost pretty!
It finds all .php files with in the current directory “find . ‘*.php’” looks for .php files in the “.” (current) directory. The result is then piped to grep using “| xargs grep” and grep then looks through it and does a caseinsencitive search for the word “customer” and returns the linenumber within the matching file.
find . -name “*.php” | xargs grep -in “customer”
Lovely!
Posted in Linux, Rock n Roll
nice little grep
In need of finding some code inside a filen within a certain folder on your server? Use this little bugger “grep -rni ‘ss_stat’ .”
Nice isn’t it? I will do a recursive grep based on your current location “.” and it will print out linenumbers where the search matches your string.
I used this grep when trying to locate ss_stats.php wihtin wordpress mu, or here used locally within a rails project:
./app/views/managers/index.html.erb:22:<%= link_to ‘New manager’, new_manager_path %>
./app/views/managers/.svn/text-base/index.html.erb.svn-base:22:<%= link_to ‘New manager’, new_manager_path %>