Jul
26
OS X Service – Word Count (and More)
Filed Under My Projects, Software Development, Computers & Tech on July 26, 2013 | 9 Comments
Inspired by a recent episode of The Mac Cast I decided to see if I could come up with a simple way of getting a word count of a PDF on OS X using only tools that come standard with the OS.
Because of OS X’s Unix underpinnings, all Macs have access to the Unix wc
command which calculates word counts on given input. OS X also has a handy built in Terminal command to access the contents of the clipboard (pbpaste
). This leads to an obvious simple manual solution:
- Open the PDF in Preview
- Select All Text
- Copy to clipboard
- Run the Terminal command:
pbpaste | wc -w
This is a bit cumbersome though, so I went on to create a simple OS X Service to calculate the word count of any selectable text in any app (the fact that this is even possible, let alone easy, is why I love OS X).
For those of you just looking for a copy of the Service, you can download it here:
To install the service simply extract the automator file from the ZIP archive and copy it into either the Library/Services
folder in your home directory, or the system-wide service folder /Library/Services
.
Once the Service is installed you can use it in almost any OS X app (specifically in any app written using the standard Cocoa libraries) by selecting some text, right-clicking on it, and selecting the Word Count service:
When done the results will look something like this:
Those of you who want to see how easy this Service was to write, read on and I’ll walk you through it.
Jul
19
TTT Part 7 of n – Managing Files
Filed Under System Administration, Computers & Tech on July 19, 2013 | 1 Comment
So far in this series we’ve focused mostly on the file system, looking at the details of file systems, how to navigate them, and at file permissions and metadata. We’re almost ready to move on and start looking at how processes work in Unix/Linux/OS X, but we have a few more file-related commands to look at before we do. In this instalment we’ll be looking at how to manipulate the file system, in other words, how to create files and folders, how to copy them, how to move them, how to rename them, and finally how to delete them.
Jul
13
TTT Part 6 of n – More File Permissions
Filed Under Computers & Tech, System Administration on July 13, 2013 | 7 Comments
In the previous instalment of this series we had a look at how standard Unix File Permissions worked. We looked at how to understand the permissions on existing files and folders, but not at how to change them. We also mentioned that the standard unix file permissions are now only a sub-set of the file permissions on OS X and Linux (OS X also supports file ACLs, and Linux has SELinux as an optional extra layer of security).
In this instalment we’ll start by biting the bullet and dive into how to alter standard Unix File permissions. This could well turn out to be the most difficult segment in this entire series, regardless of how big n gets, but it is very important, so if you have trouble with it, please don’t give up. After we do all that hard work we’ll end with a simpler topic, reading OS X file ACLs, and OS X extended file attributes. We’ll only be looking at how to read these attributes though, not how to alter them.