I'm so sick and fucking tired of the shitty sed and grep regex syntax. So i'm sharing a piece of Java code.
import java.io.*;
import java.util.regex.*;
public class Jsed{
public static void main (String args[]) {
Pattern p = Pattern.compile(args[0]);
try {
InputStream in = System.in;
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buf = new byte[4096];
int b;
while ((b = in.read(buf)) != -1) {
out.write(buf, 0,b);
}
Matcher m = p.matcher(new String(out.toByteArray()));
while (m.find()) {
System.out.println(m.group(1));
}
} catch(IOException io){
io.printStackTrace();
}
}
}
This enables you to use Java's Regex system in a pipe. For ex.
thinkpad :: ~/Documents % tree -if | jsed "(.*\d+_\d+_\d+.*\.jpg)"
./instagram/122252_161113958834_185772_n.jpg
./instagram/108184_164011148759_1532867_n.jpg
./instagram/122913_163463958699_13906354_o.jpg
./instagram/130322_151904900462_226310_n.jpg
Thank me later.