Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

How Can I Remove Blank Spaces Before and After a String Value?

(image) Hey, Scripting Guy! We have a custom in-house application that writes data to a log file. The problem is that the data often has a bunch of blank spaces before and after it. How can I remove all the blank spaces that come before and after my data?-- KS(image) (image) (image) Hey, KS. You might find this hard to believe, but the ...

How Can I Count the Number of Words in a Text File?

(image) Hey, Scripting Guy! How can I count the number of words in a text file?-- LA(image) (image) (image) Hey, LA. You know, this is one of those questions where the Scripting Guys outsmarted themselves. (Not that outsmarting the Scripting Guys is particularly hard to do, mind you.) For one thing, we’re writing this column on a Friday...

How Can I Read Just the Last Line of a Text file?

(image) Hey, Scripting Guy! How can I read just the last line of a text file?-- BM(image) (image) (image) Hey, BM. You know, if you’ve ever wondered how Hey, Scripting Guy! differs from other daily columns (like, say, Dear Abby), well, here’s one way. Suppose someone writes Dear Abby and says this: Dear Abby:My life is all messed up ...