APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

Renaming files


The email came from a long time customer:

"I modified a script I got off your site and it isn't working right. Here's the the script:

# [A-Z]* matches upper case names
for i in [A-Z]*
     j=`echo $i | tr '[A-Z]' '[a-z]'`
      mv $i $j

That works fine, but I wanted to do something a little different. So I did this:

# [A-Z]* matches upper case names
for i in [A-Z]*
     j=`echo $i | tr '[A-Z]' '[a-z]'`
     cat $i | sed 's/abc/def/' > $j

I swear that the files have 'abc' in them, but I always end up with empty files. If I just do "cat A* | sed 's/abc/def/'", the sed works.

So what's wrong with the script?"

My first answer was simply this:

"Nothing wrong with the script. When did you buy a Mac?"

Do you know why I said that?


Got something to add? Send me email.

Increase ad revenue 50-250% with Ezoic

More Articles by

Find me on Google+

© Anthony Lawrence

Kerio Samepage

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

While modern technology has given people powerful new communication tools, it apparently can do nothing to alter the fact that many people have nothing useful to say. (Leo Gomes)

The teaching of BASIC should be rated as a criminal offence: it mutilates the mind beyond recovery. (Edsger W. Dijkstra)

This post tagged: