 |
 |
Shell Script to alter text case, etc..
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Status:
Offline
|
|
Hi, I'm looking for a way to take some clipboard text and change it's case to UPPER or Initial Caps, or all lowercase.
Any ideas or links?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
Since you titled this with "shell script" here is a quick one to change the contents of the (unstyled) pasteboard to all upper-case:
Code:
pbpaste | awk '{print toupper($0)}' | pbcopy
or to all lower case:
Code:
pbpaste | awk '{print tolower($0)}' | pbcopy
This is only good when it is text only. If that text is styled, then the pasteboard will contain rtf, and this script will go bad in many ways. You could in theory write a awk command that would avoid the rtf command strings, but that is not worth my time.
I have a feeling that you would probably be better with an AppleScript to get the current selection and apply some text transforms, but you never really said what you want to do with this.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Status:
Offline
|
|
Thanks! It's a great place for me to start.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Jun 1999
Location: Las Vegas, NV, USA
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by headbirth:
Hi, I'm looking for a way to take some clipboard text and change it's case to UPPER or Initial Caps, or all lowercase.
Any ideas or links?
Hey that's a fun one, lemme try!
To uppercase:
Code:
pbpaste | tr 'a-z' 'A-Z' | pbcopy
To lowercase:
Code:
pbpaste | tr 'A-Z' 'a-z' | pbcopy
Initial Caps... I don't know sed, awk, and tr well enough... haha. I'll play with it, though. 
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: May 2002
Status:
Offline
|
|
WordService is great ... but I'm actually trying to write some of it's functionality into an OnMyCommand CM menu so the actions are available in the CM and the keystrokes don't conflict with apps.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|