Letters

Dave Taylor's Work the Shell, July 2012

I just wanted to say thanks to Dave for the subshell article!

I have to work with a lot of .csv files and used to take a lot of time manipulating them with a spreadsheet program, but after learning just a small bit about shell scripting (and a bit of Perl too), I've found that I can trim those large chunks of time to mere seconds and automate out the tedium and drudgery.

Since then, I continually look for as many tips as I can find about shell scripting, so please continue!


Jeff Shutt

Dave Taylor replies: Thanks, Jeff! Appreciate hearing from you.

NOOK Subscription

This isn't a complaint, as I know there have been many regarding the switch to the all-digital edition. As a NOOK Color owner, I was delighted to find issues available for purchase in the NOOK store at a low price. My question is why is there no subscription available through the NOOK store? I would be very happy to purchase a subscription through there. Until then, I'll continue purchasing individual issues, but a subscription through the NOOK store would be preferred.


Jeffery Mathis

Thanks for your support! We're definitely looking into the NOOK subscription option. Keep in mind though that if you order a subscription through LinuxJournal.com, you will receive a monthly download link that contains .epub, .pdf and on-line versions as well as .mobi. If you order through B&N, you receive only the .epub version.—Ed.

Android App

I have been reading your marvelous magazine for more than 10 years.

I recently got myself a new Android (Samsung Galaxy S2 4G) smartphone, and one of the first applications I installed was yours, so I could read your magazine anytime, day or night. But, I have been having a few issues with the app.

1) I have to enter my e-mail address (40 characters in total) every time I try to access the magazine on-line!

2) I often get the error “Subscription options are unavailable: device is off-line or service is unavailable.”

I live in the Federal Capital of Australia - Canberra and have ADSL 2+ at home, and I work for Unisys on federal government accounts, and they have very high-speed Internet access (I can't discuss further for security reasons).

The device is definitely not off-line. It shows 4–5 bars of signal strength at work and at home. I have alternated between Wi-Fi and the phone network for access, but this is really starting to bug me. I have never had any other app issues—LinkedIn, Foursquare, Groupon, Gmail, eBay, Telstra (phone carrier), Amazon, RealEstate.com.au and heaps of other apps all work perfectly.

I can't find a “debug” setting in your app or setup options, such as “save your e-mail address”.

How can I “save” my e-mail address? How can I get some debug details from the app to try to resolve the connectivity issue?


Nigel Grant

Wow, Nigel, I'm really sorry you've had so much trouble with the app. It is certainly supposed to keep your information, and although there were some on-line/off-line issues with early versions of the app, they should be largely solved now. My first recommendation would be to troubleshoot like any other oddly acting app. Try clearing all the cached data (in settings/applications), and if that doesn't help, try deleting and re-installing it. If you've moved the app to the SD card, make sure permissions are correct and so on. Hopefully, it will straighten out for you soon. Be sure to check out the .epub and .mobi versions too; they render nicely on the S2 as well. (I have the same phone myself.)—Ed.

LJ .mobi to Kindle

At Pragmatic Bookshelf, they offer their e-publication in .mobi format (among others). By giving them your Kindle's e-mail address and allowing e-mail from them on your Amazon account, they can send your publications directly to your Kindle. Is this a possibility for LJ?


Jes D. Nissen

Jes, although our distribution method doesn't currently support a direct e-mail, some fellow readers have scripted automated solutions. Check the past couple issues, or read the next letter from Ward.—Ed.

Script to Send the .mobi Version of LJ to an @kindle.com Address

I've written a Python script that fetches the monthly LJ e-mail from an IMAP server, uses the URL inside to download the .mobi version of LJ and send that to an @kindle.com address, so that when you sync your Kindle, LJ is added automatically. Just add the script to your cron job to run monthly. Feel free to share the script. You can find it at goo.gl/C2IE3.


Ward Poelmans

Ward, you rock my face off (which my teenage daughter assures me is a good thing, and not the nightmare-inducing horror scene it sounds like). Seriously, thanks a ton.—Ed.

Transition to All-Digital

I greatly miss Linux Journal in hard copy. There is no substitute for having a magazine around that you can just pick up and read anytime, anywhere. The electronic version, despite having some advantages, simply fails to match the hard-copy experience.

Now, I have passed through the grieving process—denial, anger, bargaining, depression—and have come to acceptance. As such, I will continue to subscribe, because Linux Journal is part of the Linux ecosystem, and I want the ecosystem to grow and evolve, even if occasionally some changes displease me.

Since you have gone all electronic, please adapt your style to the new media. It's no longer print, so lose the print format and capitalize on the possibilities of digital. Two columns don't work on displays that don't show a complete page; some of the images need higher resolution (the photos of Reuven and the Silicon Mechanics and iXsystems advertisements in the July issue, for example); cut the publishing cycle to be more timely; don't go overboard with multimedia, but include it when it enhances the exposition and works creatively.

It is going to be hard going for you and your loyal readers, but I am prepared to continue to support Linux Journal through this difficult time.


Gordon Garmaise

Gordon, I understand your process, and even though I had to put on a happy face, I may have had some similar emotions! We have modified the PDF version significantly to look better on devices, yet still retain the magazine look and feel. If you've seen the PDF on a 10" tablet, it's pretty stunning. Hopefully, the .epub and .mobi versions with their flowing text help with other devices.—Ed.

Love the E-Format

I've read numerous rants and raves about the digital format of Linux Journal, and I felt the need to chime in with some positive feedback. Personally, I love the digital format. It's the reason I renewed my LJ subscription. Almost all the magazines I used to read in paper, I now look for in digital format. It's much more portable, and I no longer have to worry about having stacks of magazine copies piled under the coffee table or lined up on my bookcase. The electronic version is also much more interactive. If a person wants to learn more about a particular article topic or an interesting product in an ad, there's usually a hyperlink to click on. I would like to see all magazines at least offer a digital option for those of us who prefer bytes over tree bark.


Jim Vaughn

Thanks Jim! It's certainly been a polarizing topic, that's for sure.—Ed.

Regarding My Letter to Dave Taylor in the Last Issue

I just read Dave Taylor's July 2012 column. Keeping in the same vein as before, I want to see if these comments to Dave help.

You refer to how you can build up a command and then save it by saying:

!! > new-script.sh

This will not save the command. It will run the last command and save its output. If you want to save the last command, you want to say either:

!!:p > new-script.sh

or:

echo "!!" > new-script.s

They are almost the same but not quite. By the way, the !! syntax is from the C shell and is a part of Bash as well. It is not a part of the Bourne shell or ksh.

You show how useful subshells can be:

newname=$(echo $filename | sed 's/.JPEG/.jpg/')

In fact, this is massive overkill. The $() is a subshell. The echo is built in, so no subshell there. Then, you use sed with all of its footprint that is capable of powerful regex manipulations, for a total of two subprocesses. Instead, how about a simpler approach:

newname="${filename/.JPEG/.jpg}"    # Look Ma! No subprocesses.

How graceful is the continuation of a multi-line command? But, there's no mention of PS2. Anyone who uses it will not see the default that you have.

Telling people to use a for file in $(grep -l stuff...) is bad practice. The construct will fail if the filenames have embedded whitespace. Also, it will fail if the list is large, because you will violate the maximum length of a command. (Commands do have a max length.)

The proper way to do it is either to use a while read loop, or to use find | xargs. It's almost always a bad idea to use find -exec:

find . -type f -print0 | xargs -0 grep -l stuff

The same thing using while read and process substitution might be:


while read fn
do
    do_something_with $fn
done <(< find | xargs...)

This is exactly two subprocesses.

You mentioned a 250-line script (scale), but you don't tell us where it is so we can see it. But, it bears mentioning that there is a big difference between options and their possible option arguments, and command arguments.

Instead of:

scale {args} factor [file or files]

your terminology should be:

scale [options] factor [file-list]

The use of square brackets is to denote optional use. I strongly encourage you to read the Bash man page.

Looking forward to the next one.


Steven W. Orr

Thanks for Covering the Basics

I just read your column in the July 2012 Linux Journal (“Subshells and Command-Line Scripting”) and wanted to say thanks. Although your other shell articles provide insight into using the shell, I usually end up planning to read those in depth sometime later, and then don't. I enjoy articles that explain the basics in more depth. While I am not a newbie (I started more seriously when Fedora Core 1 came out), I am not very advanced. My occupation was as a toolmaker at an R&D facility, and my family consumed (I'm now retired) much of my time and thought. I am probably still, at best, a beginning-intermediate Linux adherent/user. I want to develop a much deeper understanding of all aspects of how Linux works, and how to put it to work, but since my stem-cell transplant, I find it a little more difficult to learn and retain knowledge. I have found this article very helpful, as are those of many of the other Linux Journal contributors. Thanks to you and all of the others for your efforts. By the way, I used e-mail because I am not really a Web 2.0 kind of guy. My wife and I don't use social media. Thanks for providing this avenue of communications too.


jjerome1

Dave Taylor replies: Thanks for your kind note. It's nice to know people are a) reading and b) appreciating what I write.

Texterity Android App

When LJ came out in .epub format, I immediately put it on my Kobo and my Android phone. The Kobo is a tad underpowered, so it's hard to flip through a magazine quickly, so I've been using my Android phone more lately, on a 4.3" screen.

The built-in .epub reader is good, and the .epub reflows nicely, but I decided to try the LJ app to see if I like it.

Pros: 1) annotations allow one to jump to a specific article, and 2) pure text mode helps the content fit the screen, which is good for small displays.

Con: it doesn't remember where I left off!

This “con” is huge, an obviously needed feature, and a terrible oversight unless I'm missing some hidden setting in the app. The built-in .epub reader opens right to where I left off. In the LJ app, if I jump to another app temporarily and then go back in, the book is closed, and it doesn't know where I was. Even if I go into an annotation, and then click the back button, it doesn't remember where in the page I was. Web browsers work better than this, so this is simply not acceptable. Find a Texterity developer and smack them with a cluebat.

Also, if the Wi-Fi is enabled, when I go back into the app after briefly looking elsewhere, it tries to reload all the books again!

I was in a coffee shop with spotty Wi-Fi and I had to disable my Wi-Fi because every time I looked elsewhere, like my calendar, and went back into the LJ app, it insisted on trying to download the issue again!

I'm running it on Gingerbread, so I don't know if these issues are fixed already elsewhere, but I'm amazed that anyone let the software out the door in this condition, as the user experience is not good compared with a simple .epub reader, which is what I'll be using.

Keep up the good work and sorry for ranting. Maybe it's just me, since I would think that these issues would be serious enough to prevent the release of the app.


Mike

Thanks for the feedback, Mike. We'll make sure to get the info to the Texterity folks. Sadly, cluebats aren't indigenous to my area, so I may have to smack them with a fruit bat instead.—Ed.

Why Not Have a Happy Funeral for the Paper Version of LJ?

All right, I must admit that during the past few months I have attempted to try to guess which page the Letters to the Editor would end and start reading from there. The only other place I have heard more complaining has been at church if people thought the song service was too long, too short, not enough traditional songs, not enough new songs, not my newly written song, and I haven't even touched the minster's message critiques!

I have been reading an interesting book titled How to Change your Church Without Killing It. An intriguing chapter in the book describes how leaders need to honor areas of ministry that have run their course before phasing them out. This got me looking back at all of the writers over the months that have been angry about the removal of the paper version of their favorite magazine. I understand the economics of business and am not suggesting you do something that would jeopardize your bottom line, but I do think there is a solution to help those who are angry and disappointed about the absence of their physical magazine. Why not rejoice in the articles of the past? Summon all past subscribers of the print edition to tell you which paper article was the best in their opinion. Rejoice and give credit to those who got their fingers dirty at the printing press. It just may cause some disgruntled folks to come back just because you are allowing them the opportunity to thumb through their old magazines and relive the moments of breaking off work early to get to the mail box for the magazine. They may start to await the e-mail prompt: “Your Issue of Linux Journal has arrived and is ready for download”.

If people have a chance to rejoice and relive their positive experiences of the past, they may just come back!


Dean Anderson

Dean, that's an interesting idea. We'll toss it around a bit and see if we can come up with something. I still have quite a stack of Linux Journal issues I can't bear to part with. (The arcade machine article in the August 2007 issue was the first time I was ever published. Issue 160 will always have a home on my coffee table! See www.linuxjournal.com/article/9732.)—Ed.

Photo of the Month

I'd like to share this photo with readers.


Tim O'Grady

Are you an emacs or vi roo?