SlideShare uma empresa Scribd logo
1 de 11
CIS 216 Unix Scripting
Highline Community College
        Dan Morrill
 When working with case you want to read input:
   read choice
   cd $choice
      This reads the input from the keyboard and then changes the
       directory over to the one specified by the user. Choice is
       read, and then used as a variable
 You can do this anywhere in a script for just about any
 thing you can do on a Linux Box
   read UserProcess
   ps –ef |grep $UserProcess
1.   FRUIT="kiwi"
2.   case "$FRUIT" in
3.     "apple") echo "Apple pie is quite tasty."
4.     ;;
5.     "banana") echo "I like banana nut bread."
6.     ;;
7.     "kiwi") echo "New Zealand is famous for kiwi."
8.     ;;
9.   esac
 In this program we see Fruit is set = “kiwi”
 The case statement reads the $Fruit and where there is
  a match, in this case kiwi, outputs the text:
 New Zealand is famous for kiwi


 If we wanted to change this so that user input was
  considered we would change:
   Read Fruit
   echo “allowed entries are apple, banana, and kiwi”
   remember case sensitivity.
 choiceA || continue
 If no conversion needs to be done, a continue
 statement restarts execution of the loop.
   the “||” = to a logical OR
   [ “$choiceA] or continue
 The tput utility uses the terminfo database to make
 the values of terminal-dependent capabilities and
 information available to the shell, to initialize or reset
 the terminal, or return the long name of the requested
 terminal type. tput outputs a string if the attribute
 (capability name) is of type string, or an integer if the
 attribute is of type integer. If the attribute is of type
 boolean, tput simply sets the exit code (0 for TRUE if
 the terminal has the capability, 1 for FALSE if it does
 not), and produces no output.
1. case $RCOUNT in
2.   1) tput cup 2 0; echo -e "- L.    bc"
3.     sleep $INTERVAL
4.     ;;

 Case using a counting variable $RCOUNT
 TPUT CUP (Position the cursor on the screen to XY 2
  and 0 echo the letter L
 Sleep for the variable $INTERVAL
 To change the color of the text, use the setb option for setting the
    background color and the setf option for setting the foreground
    color along with the number of the color assigned in the
    terminfo database. The following numbers and colors are
    typically assigned but may vary from each UNIX system:
   0: Black
   1: Blue
   2: Green
   3: Cyan
   4: Red
   5: Magenta
   6: Yellow
   7: White
 tput cup 2 0; echo -e " Lo..        bc“
 To
 tput setf 4 cup 2 0; echo -e " Lo..         bc“

 To have a foreground color of Red
 setf = foreground color
 setb = background color
   This is bad for people who are color blind and not using
       the standard terminal coloring
1.    INTERVAL=1000 # Sleep time between rotation intervals
2.    RCOUNT="0" # For each RCOUNT the line rotates 1/8
3.         # cycle

4.    while : # Loop forever...until this function is killed
5.    do
6.      (( RCOUNT = RCOUNT + 1 )) # Increment the RCOUNT

7.      case $RCOUNT in
8.      1) tput cup 2 0; echo -e "- L.      bc"
9.        sleep $INTERVAL
10.       ;;
11.     2) tput cup 2 0; echo -e " Lo..    bc"
12.       sleep $INTERVAL
13.       ;;
Understanding UNIX CASE and TPUT

Mais conteúdo relacionado

Semelhante a Understanding UNIX CASE and TPUT

If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongMario Fusco
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsSunil Kumar Gunasekaran
 
Licão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationLicão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationAcácio Oliveira
 
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...Mark Simon
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADDharmalingam Ganesan
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to RakuSimon Proctor
 
The swift programming language
The swift programming languageThe swift programming language
The swift programming languagePardeep Chaudhary
 
CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2johnnygoodman
 
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl   finer points ,pack&unpack,eval,filesAdvanced perl   finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,filesShankar D
 
CLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaCLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaVijiPriya Jeyamani
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial javaTpoint s
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Workhorse Computing
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughterQuinn Wilton
 

Semelhante a Understanding UNIX CASE and TPUT (20)

If You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are WrongIf You Think You Can Stay Away from Functional Programming, You Are Wrong
If You Think You Can Stay Away from Functional Programming, You Are Wrong
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applications
 
Licão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationLicão 12 decision loops - statement iteration
Licão 12 decision loops - statement iteration
 
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
The Swift Programming Language - Xcode6 for iOS App Development - AgileInfowa...
 
php_string.pdf
php_string.pdfphp_string.pdf
php_string.pdf
 
Load-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOADLoad-time Hacking using LD_PRELOAD
Load-time Hacking using LD_PRELOAD
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to Raku
 
The swift programming language
The swift programming languageThe swift programming language
The swift programming language
 
ch08.ppt
ch08.pptch08.ppt
ch08.ppt
 
Perl_Part2
Perl_Part2Perl_Part2
Perl_Part2
 
CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2CPAP.com Introduction To Coding: Part 2
CPAP.com Introduction To Coding: Part 2
 
OS.pdf
OS.pdfOS.pdf
OS.pdf
 
Advanced perl finer points ,pack&unpack,eval,files
Advanced perl   finer points ,pack&unpack,eval,filesAdvanced perl   finer points ,pack&unpack,eval,files
Advanced perl finer points ,pack&unpack,eval,files
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
CLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaCLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriya
 
C programming language tutorial
C programming language tutorial C programming language tutorial
C programming language tutorial
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
 
Software to the slaughter
Software to the slaughterSoftware to the slaughter
Software to the slaughter
 

Mais de Dan Morrill

Windows power shell basics
Windows power shell basicsWindows power shell basics
Windows power shell basicsDan Morrill
 
Understanding web site analytics
Understanding web site analyticsUnderstanding web site analytics
Understanding web site analyticsDan Morrill
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingDan Morrill
 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingCreating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingDan Morrill
 
Information security principles
Information security principlesInformation security principles
Information security principlesDan Morrill
 
Using Regular Expressions in Grep
Using Regular Expressions in GrepUsing Regular Expressions in Grep
Using Regular Expressions in GrepDan Morrill
 
Understanding the security_organization
Understanding the security_organizationUnderstanding the security_organization
Understanding the security_organizationDan Morrill
 
You should ask before copying that media
You should ask before copying that mediaYou should ask before copying that media
You should ask before copying that mediaDan Morrill
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scriptingDan Morrill
 
Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Dan Morrill
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewDan Morrill
 
What is cloud computing
What is cloud computingWhat is cloud computing
What is cloud computingDan Morrill
 
Social Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleSocial Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleDan Morrill
 
Case Studies In Social Media Chinese
Case Studies In Social Media ChineseCase Studies In Social Media Chinese
Case Studies In Social Media ChineseDan Morrill
 
Case Studies In Social Media
Case Studies In Social MediaCase Studies In Social Media
Case Studies In Social MediaDan Morrill
 
Turn On Tune In Step Out
Turn On Tune In Step OutTurn On Tune In Step Out
Turn On Tune In Step OutDan Morrill
 
Technology And The Future Of Management
Technology And The Future Of ManagementTechnology And The Future Of Management
Technology And The Future Of ManagementDan Morrill
 

Mais de Dan Morrill (18)

Windows power shell basics
Windows power shell basicsWindows power shell basics
Windows power shell basics
 
Understanding web site analytics
Understanding web site analyticsUnderstanding web site analytics
Understanding web site analytics
 
Process monitoring in UNIX shell scripting
Process monitoring in UNIX shell scriptingProcess monitoring in UNIX shell scripting
Process monitoring in UNIX shell scripting
 
Creating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scriptingCreating a keystroke logger in unix shell scripting
Creating a keystroke logger in unix shell scripting
 
Information security principles
Information security principlesInformation security principles
Information security principles
 
Using Regular Expressions in Grep
Using Regular Expressions in GrepUsing Regular Expressions in Grep
Using Regular Expressions in Grep
 
Understanding the security_organization
Understanding the security_organizationUnderstanding the security_organization
Understanding the security_organization
 
You should ask before copying that media
You should ask before copying that mediaYou should ask before copying that media
You should ask before copying that media
 
Cis 216 – shell scripting
Cis 216 – shell scriptingCis 216 – shell scripting
Cis 216 – shell scripting
 
Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)Understanding advanced persistent threats (APT)
Understanding advanced persistent threats (APT)
 
AWS Hadoop and PIG and overview
AWS Hadoop and PIG and overviewAWS Hadoop and PIG and overview
AWS Hadoop and PIG and overview
 
What is cloud computing
What is cloud computingWhat is cloud computing
What is cloud computing
 
Social Media Plan for CityU of Seattle
Social Media Plan for CityU of SeattleSocial Media Plan for CityU of Seattle
Social Media Plan for CityU of Seattle
 
BSIS Overview
BSIS OverviewBSIS Overview
BSIS Overview
 
Case Studies In Social Media Chinese
Case Studies In Social Media ChineseCase Studies In Social Media Chinese
Case Studies In Social Media Chinese
 
Case Studies In Social Media
Case Studies In Social MediaCase Studies In Social Media
Case Studies In Social Media
 
Turn On Tune In Step Out
Turn On Tune In Step OutTurn On Tune In Step Out
Turn On Tune In Step Out
 
Technology And The Future Of Management
Technology And The Future Of ManagementTechnology And The Future Of Management
Technology And The Future Of Management
 

Último

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 

Último (20)

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Understanding UNIX CASE and TPUT

  • 1. CIS 216 Unix Scripting Highline Community College Dan Morrill
  • 2.  When working with case you want to read input:  read choice  cd $choice  This reads the input from the keyboard and then changes the directory over to the one specified by the user. Choice is read, and then used as a variable  You can do this anywhere in a script for just about any thing you can do on a Linux Box  read UserProcess  ps –ef |grep $UserProcess
  • 3. 1. FRUIT="kiwi" 2. case "$FRUIT" in 3. "apple") echo "Apple pie is quite tasty." 4. ;; 5. "banana") echo "I like banana nut bread." 6. ;; 7. "kiwi") echo "New Zealand is famous for kiwi." 8. ;; 9. esac
  • 4.  In this program we see Fruit is set = “kiwi”  The case statement reads the $Fruit and where there is a match, in this case kiwi, outputs the text:  New Zealand is famous for kiwi  If we wanted to change this so that user input was considered we would change:  Read Fruit  echo “allowed entries are apple, banana, and kiwi”  remember case sensitivity.
  • 5.  choiceA || continue  If no conversion needs to be done, a continue statement restarts execution of the loop.  the “||” = to a logical OR  [ “$choiceA] or continue
  • 6.  The tput utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell, to initialize or reset the terminal, or return the long name of the requested terminal type. tput outputs a string if the attribute (capability name) is of type string, or an integer if the attribute is of type integer. If the attribute is of type boolean, tput simply sets the exit code (0 for TRUE if the terminal has the capability, 1 for FALSE if it does not), and produces no output.
  • 7. 1. case $RCOUNT in 2. 1) tput cup 2 0; echo -e "- L. bc" 3. sleep $INTERVAL 4. ;;  Case using a counting variable $RCOUNT  TPUT CUP (Position the cursor on the screen to XY 2 and 0 echo the letter L  Sleep for the variable $INTERVAL
  • 8.  To change the color of the text, use the setb option for setting the background color and the setf option for setting the foreground color along with the number of the color assigned in the terminfo database. The following numbers and colors are typically assigned but may vary from each UNIX system:  0: Black  1: Blue  2: Green  3: Cyan  4: Red  5: Magenta  6: Yellow  7: White
  • 9.  tput cup 2 0; echo -e " Lo.. bc“  To  tput setf 4 cup 2 0; echo -e " Lo.. bc“  To have a foreground color of Red  setf = foreground color  setb = background color  This is bad for people who are color blind and not using the standard terminal coloring
  • 10. 1. INTERVAL=1000 # Sleep time between rotation intervals 2. RCOUNT="0" # For each RCOUNT the line rotates 1/8 3. # cycle 4. while : # Loop forever...until this function is killed 5. do 6. (( RCOUNT = RCOUNT + 1 )) # Increment the RCOUNT 7. case $RCOUNT in 8. 1) tput cup 2 0; echo -e "- L. bc" 9. sleep $INTERVAL 10. ;; 11. 2) tput cup 2 0; echo -e " Lo.. bc" 12. sleep $INTERVAL 13. ;;

Notas do Editor

  1. http://www.tutorialspoint.com/unix/case-esac-statement.htm
  2. http://www.ibm.com/developerworks/aix/library/au-learningtput/