The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Special Forums > UNIX Desktop for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 06-10-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,407
small changes req...

Code:
while read line ;do 
words = `echo "$line" |wc -w`  // counting the words of current line
##OR###
###words=` echo "$line" |awk '{print NF}'`####

If [ $((words % 2)) –eq "0" ] ; then // see if number of words is even 
echo "$line" | tr '[a-z]' '[A-Z]' >> outputfile.txt // if even, change all to uppercase and copy to another file 
else
echo "$line" | tr '[A-Z]' '[a-z]' >> outputfile.txt // else; odd, change all to lowercase
fi
done < File1