|
From: | Jonathan Kulp |
Subject: | Re: Lilypond & Ubuntu Help |
Date: | Sun, 17 Aug 2008 22:22:41 -0500 |
User-agent: | Thunderbird 2.0.0.16 (X11/20080724) |
I didn't even know the basename command until today when I started researching the problem. I have a book to thank for that. The book and the manpage for basename both mention the extension-chopping function. Very useful. I was using a sed command to do that before, but I like basename better b/c I didn't really understand what sed was doing, I just copied and slightly tweaked someone else's line of code in another script (sort of like what we do with lilypond snippets, I guess). The advantage of sed over basename for this, though, is that sed doesn't require you to specify exactly what the extension is that you want to chop off. I tried using "basename ~/Documents/filename.ly .*" and it returned errors. You have to tell it exactly what extension you want to extract: "basename ~/Documents/filename.ly .ly" returns "filename". This is fine for a script designed specifically for lilypond, but it would be more flexible if it allowed for a wildcard that would chop off whatever extension happened to be there.
The book is "Beginning Shell Scripting," by Eric Foster-Johnson, John Welch, and Micah Anderson. I also have "Classic Shell Scripting," an O'Reilly book, but I find that Beginning Shell Scripting is better about explaining every detail of every example, which is important for me since I'm such a newb :).
Thanks for writing the script, Jay. I'm going to study and break it down bit by bit to see what I can learn from it. It works great!
Jon Jay Anderson wrote:
The scripts do essentially the same thing. The only thing I was trying to do was allow for normal lilypond command line arguments also. The sed line is a hack to pull out all but the last argument. It will break if the last argument is quoted and has a space in it. -----Jay P.S. I didn't know basename took a second argument to chop off the extension. Neat.
-- Jonathan Kulp http://www.jonathankulp.com
[Prev in Thread] | Current Thread | [Next in Thread] |