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

Renaming files


© November 2006 Anthony Lawrence

2006/11/21

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]*
do
     j=`echo $i | tr '[A-Z]' '[a-z]'`
      mv $i $j
done

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]*
do
     j=`echo $i | tr '[A-Z]' '[a-z]'`
     cat $i | sed 's/abc/def/' > $j
done

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?

Answer


Got something to add? Send me email.





(OLDER)    <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

->
-> Renaming files


Inexpensive and informative Apple related e-books:

Digital Sharing Crash Course

El Capitan: A Take Control Crash Course

Take Control of Upgrading to El Capitan

iOS 10: A Take Control Crash Course

Take Control of High Sierra




More Articles by © Anthony Lawrence




Printer Friendly Version

Have you tried Searching this site?

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


Printer Friendly Version





I am not out to destroy Microsoft, that would be a completely unintended side effect. (Linus Torvalds)




Linux posts

Troubleshooting posts


This post tagged:

Detective



Unix/Linux Consultants

Skills Tests

Unix/Linux Book Reviews

My Unix/Linux Troubleshooting Book

This site runs on Linode





SCO Unix Sales, Support, & Service

Phone:  707-SCO-UNIX (707-726-8649Toll Free: 833-SCO-UNIX (833-726-8649)
www.SCOsales.com