Apr. 27th, 2016

jbanana: Badly drawn banana (Default)
The command prompt in Unix/Linux has always let you do fancy stuff. For example, here's one way to edit all the Java code that contains "someSearchString":
find . -name "*.java" -exec grep -q "someSearchString" '{}' \; -exec someEditor '{}' \;
On Windows, the command prompt is less rubbish than used to be. Here's one way to do the same task:
for /f "tokens=*" %G in ('dir /s /b *.java') do @(find "someSearchString" >nul && someEditor %G)
I like the way that both examples use find but it means something completely different.

Edit: one obvious difference: the *nix version ill search for a regex, but Windows will only do plain text
Bnother edit: simplified the Windows version by redirecting to NUL.

July 2017

M T W T F S S
     12
3456789
10111213141516
17 181920212223
24 252627282930
31      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 26th, 2017 04:28 am
Powered by Dreamwidth Studios