Recursive Grep Example
November 20, 2009 Leave a comment
Nothing really needing explaining here, but wanted an example for doing a recursive grep handy as I can never remember it.
grep -RH –include “*.java” TEXT_I_AM_LOOKING_FOR *
tech junk, maybe a rant or two
November 20, 2009 Leave a comment
Nothing really needing explaining here, but wanted an example for doing a recursive grep handy as I can never remember it.
grep -RH –include “*.java” TEXT_I_AM_LOOKING_FOR *
May 15, 2009 1 Comment
There are so many versions of Bash around and it can be frustrating, to me at least, to do some things for not knowing what is available on a given machine. Well here is one, the for loop. Here are a few different ways to do the same thing (and I am sure there are many others) . The first two below work on current linux machines but only the third works on Solaris 5.8’s version of Bash. Enjoy
for ((i=0;i<=5;i+=1)); do echo anda$i; done; for seq 6 7; do echo anda$i; done; for i in 8 9 10 11 12; do cvs tag -d anda$i; done;
January 19, 2009 2 Comments
2011 edit
As of Mac OS X 10.7 (Lion), this can now be done as a Service (not exactly like KDE, but better than nothing). Go to:
System Preferences > Keyboard > Keyboard Shortcuts > Services
Then check the box to enable “New Terminal at Folder”
Then when you are in the Finder and want to open a terminal right there, right click on the folder name and at the bottom of the menu you will see the “New Terminal” link. You can also drag the folder and drop it onto the terminal icon.
————– 2009 post ————
Before OSX came along, making the Mac usable, I was always mainly a Linux user and became very used to the KDE and Gnome UI and features. When getting into the OSX, I really missed certain things and just had to figure out how to add em, to be comfortable. This is one big one. Though I usually use a Shell and Midnight Commander to get around in my Linux systems, from time to time I would end up in the KDE GUI File browser thing, and end up using their cool “Open a terminal here” command, to get to the Shell and do stuff. Since we are mostly in a GUI environment when using OSX, this feature was killing me. But, there is a simple way to add this thanks to the Automator and Apple Script. Here is what I found (though I do not remember where) when looking at how to do this.
on run {input, parameters}
tell application "Finder"
set winOne to window 1
set winOnePath to (quoted form of POSIX path of (target of winOne as alias))
tell application "Terminal"
activate
tell window 1
do script "cd " & winOnePath
end tell
end tell
end tell
return input
end run
[user home]/Library/Workflows/Applications/Finder
and name the file something that you want the Menu to show when you go to use this new Automator command (I used “term-here” for instance)
But if you are in Snow Leopard, then you have a service and “Save-As” only prompts you for a name. I entered “term-here”.
Once these steps are completed and the file saved, you should be able to open the Finder, navigate to a directory you wish to open a Terminal in, right click in the directory, choose “Automator” and see you new command there. Choosing the command should pop up a new Terminal with the working directory set to the directory you were in.
NOTE, of course if you are on Snow Leopard it is different. Here you need to choose the dir you want with the pointer and right click. To get the current directory, I choose to view the path bar from the Finder’s View menu, and then I can choose the dir I am in and click. I also created a keyboard shortcut for it. To create a keyboard shortcut, when in the Finder, choose Services from the Finder menu, then Services Preferences, then scroll down to find your new service. Click into the white space to the right of your service to get the entry box for your shortcut, and then use the keys you want to be the shortcut, as if you were trying to launch it right now, and it will store them in the box for you.
Enjoy
j
January 16, 2009 Leave a comment
To set up a Debian Linux machine to handle UTF-8 in a shell or console app do the following.
First, use dselect or whatever tool you like to find the Japanese font packages for X and install em.
Then run
dpkg-reconfigure locales
then choose en_US.UTF-8
Test by executing the folowing in a shell:
locale charmap
it should say
UTF-8
If not try just
locale
it should have UTF-8 for everything like:
LANG=en_US.UTF-8
LANGUAGE=en_US:en_GB:en
LC_CTYPE=”en_US.UTF-8″
LC_NUMERIC=”en_US.UTF-8″
LC_TIME=”en_US.UTF-8″
LC_COLLATE=”en_US.UTF-8″
LC_MONETARY=”en_US.UTF-8″
LC_MESSAGES=”en_US.UTF-8″
LC_PAPER=”en_US.UTF-8″
LC_NAME=”en_US.UTF-8″
LC_ADDRESS=”en_US.UTF-8″
LC_TELEPHONE=”en_US.UTF-8″
LC_MEASUREMENT=”en_US.UTF-8″
LC_IDENTIFICATION=”en_US.UTF-8″
LC_ALL=en_US.UTF-8
if not then Add the follwoing to .bashrc and re-source it (e.g. get a new login shell, or execute bash)
export LC_ALL="en_US.UTF-8"
then try
locale charmap
or
locale
once that is all set to UTF-8 then change your shells (xterm, rxvt) to use:
uxterm
urxvt
That is it. I had to exit X11 and re-login to get X11 to take these settings
so that clicking my icon for xterm launched uxterm WITH the correct environment
After this all console apps that can handle UTF-8 (like vim) display UTF-8
characters correctly.