![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX Desktop for Dummies Questions & Answers Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office here. All UNIX and Linux Newbies Welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| uppercase to lowercase | ajit.yadav83 | UNIX for Dummies Questions & Answers | 4 | 10-16-2008 11:36 AM |
| Lowercase to Uppercase | ggovotsis | AIX | 7 | 10-16-2008 10:07 AM |
| UPPERCASE to lowercase with no overwriting? | lgd923 | Shell Programming and Scripting | 1 | 08-21-2008 08:13 AM |
| How convert lowercase or uppercase | Alex20 | Shell Programming and Scripting | 5 | 03-07-2005 07:07 AM |
| uppercase to lowercase | webex | Shell Programming and Scripting | 4 | 01-03-2002 02:15 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Unix: lowercase to uppercase
I just started to learn unix...
and i needed to make a basic script. i need to 1. read a file (.txt) 2. count the words of EVERY sentece 3. sentences with odd number of words need to be converted into lowercase sentences with even number of words need to be converted into uppercase 4.the translation needs to be written into a different file I just can't sepperate the sentences and count the words of every sentance appart. can someone help me thx |
|
||||
|
We do not do homework for you. This is clearly homework.
1. use a while read record .. do ... done <inputfilename loop. This reads the file line by line. 2. tr will uppercase or lowercase a whole sentence. 3. wc -w will count the words. Next, you get to show us what you've done with this. |
|
||||
|
I have not test it yet, because im still dowloading opensuse
could this work? while read line do words = wc –w $line // counting the words of current line If [ $(($words % 2)) –eq 0] Then // see if number of words is even echo $File1 | tr '[a-z]' '[A-Z]' < $File2 // if even, change all to uppercase and copy to another file Else echo $File1 | tr '[A-Z]' '[a-z]' < $File2 // else; odd, change all to lowercase Fi Done < File1 |
|
||||
|
so if i would change the < into > it should be right?
> is overwriting the file >> is adding 'content' to the file... i think... so it should be >>file2 edit: ow right... vidyadhar85 just said it... thx Last edited by chilli1988; 06-10-2009 at 06:52 PM.. |
| Sponsored Links | ||
|
|