Friday, January 27, 2012

Using -exec instead of xargs

Using xargs to pipe results of find into grep has problems if find returns files/folders with spaces in the name.

find ./ -name "*html" | xargs grep "something"


Ends up giving me lots of "file doesn't exist" errors.

Using exec circumvents this problem, although using exec is apparently a less efficient way of doing things.

find ./ -name "*html" -exec grep -H "something" "{}" \;

-H tells grep to always show the filename, otherwise you only get the match.
"{}" represents the filename returned by find.
\; I'm not sure what this is, but it has to be there...

Update:
I describe a slightly simpler solution in this posting.

Friday, January 20, 2012

Open MS Office documents with MS Office through nautilus

See reply below for updated solution.

The general form is: wine "C:\path\to\irfanview" '""Z:%f""'

So for MS word for instance:
  Right click on .docx file and select open with-> custom
  Enter the following: 


wine "c:\Program Files\Microsoft Office\Office12\WINWORD.EXE" '""Z:%f""'


The Z and %f have to do with the fact that wine apps locate Linux files through the virtual z: drive, and %f inserts a filename.