Archive for ‘UNIX’

Disable the Character Picker in OS X

Posted on: July 31st, 2013 by Dan Robert

OS X 10.7 (Lion) introduced a feature called the Character Picker. This allows you to press-and-hold a key on your keyboard, activating a little popup with the different character options associated with that key. This can be a useful feature for some, as it allows you to visually see all of those additional character options and not have to know how to otherwise activate each of them. I, however, found that it was more of a hinderance to my workflow. For example, when I am editing my code in VIM or Vintage Mode in Sublime Text, this feature prevents me from holding down the movement keys (h, j, k, l) to navigate. So I decided to disable it.

(more…)

Secure Copy Syntax Examples

Posted on: September 17th, 2012 by Dan Robert

Secure Copy (SCP) is a means of securely transferring files between hosts on a network. It is based on the Secure Shell (SSH) protocol. The command line scp program, which is provided in most SSH implementations, is the secure analog of the rcp command.

The syntax for scp is typically similar to that of the cp command.

Examples

Copying from a remote host to your local host:

# Copy a file
scp username@remotehost.com:sourcefile.txt /path/to/local/targetfile

# Copy a directory
scp -r username@remotehost.com:sourcefolder /path/to/local/targetfolder
(more…)

Super Fast Find and Replace with Sed

Posted on: August 27th, 2012 by Dan Robert

Sed is a UNIX stream editor that can be used to filter text files. This can be extremely useful if you have to run a Find and Replace on a string of text across a large file. I find this to be much more efficient than using a Find and Replace feature in a text editor. It is much faster (especially on very large files) and you can let it run in a separate Terminal tab without holding up your workflow.

So how does it work? It’s pretty straightforward. You need to know the location of the file you wish to edit relative to your current directory. You will also need to know the string you are looking to update. The syntax looks something like the following:

sed -i “.backup” 's/string-to-find/string-to-replace/g' path/to/file
(more…)

Viewing Apache Logs with Tail and Grep

Posted on: August 21st, 2012 by Dan Robert

As a developer, there may be times when you need to monitor what is happening on an Apache server as live HTTP requests are coming in from a web page. In a UNIX environment, you can actually accomplish this quite painlessly through the command line, using the tail and grep commands. Tail is a command which outputs the last part of a file and the grep utility is used for pattern matching.

First, you will want to locate your Apache logs and cd into that directory. If you are running a local server through MAMP, you can most likely find them in the application folder.

cd /Applications/MAMP/logs
(more…)