SlideShare una empresa de Scribd logo
1 de 12
Remembering the basics – Week 1
   Dan Morrill April 01 2013
 RMDIR – removes a directory only if it is empty
 RMDIR –r – removes a directory regardless if it is
  empty or not
 CHMOD 777 –r /user/dan – recursively changes the
  permissions of the directory /user/dan to
  RWXRWXRWX
 grep – pattern matching for example ps –ef |grep
  apache2 will look for all processes running under the
  name apache2
   egrep – used in regular expressions
 find – find the location of a file (or files) on a hard
  drive at the command line
 echo – writes data to the screen (standard output)
   The TTY – Screen is always standard output (STDOUT)
 more – displays the contents of a file one page at a time
  (hard for long files like syslog)
 clear – clears the screen of text and provides the
  command prompt
 chown – change the owner of a file or directory
 rm – remove a file
 mv – move a file to a new place and or new name
 chgrp – change the group ownership of a file
 mkdir – make a directory
 ls – list the files in a directory, ls –la show the long
  form (including permissions and owners) of the files
  in a directory
 cat – an alternative to showing the data in a file all at
  once
 pwd – display the current directory
 passwd – change the password of the currently logged
  in user
 >> - append data to the END of a file
 > - overwrites the file and any data in it
 | - pipe character – strings commands together
 || - logical OR – in that A || B in a loop, condition A or
  condition B
 & - executes your process in the background – so you can
  still use the command line ./script.sh & will run your
  process in the background
 && - Logical AND A && B if A succeeds, run B
 sleep – stop execution of the script for a specified number
  of seconds sleep 20 means sleep for 20 seconds
 diff – compares two files (this is great for seeing what
    changes were made in a script against the original and
    modified)
   sdiff – only works with the 132 character display, but
    compares files side by side
   lp – prints a file to the configured printer
   lpstat – shows the user what is in the printer queue
   ( ) – runs the enclosed command in a sub-shell
   (( )) – evaluates and assigns a value to a variable and
    does math in a sub-shell
 $(( )) – evaluates the enclosed expression
 [ ] – test an expression to see if it is true or false
 < > - used to compare values or strings
 $( ) – command substitution – great when doing
  logical OR’s or AND’s
 ++ - auto increment a value for I=1 ++ (takes I up by 1
  for every loop)
 -- - auto decrement a value for I=100 -- (takes I down
  by 1 for every loop)
 <= - less than or equal to
 >= - greater than or equal to
 I will expect to see this in the header of every Unix Script
    you will turn in:
   #!/bin/sh (tells the computer to use a bourne shell)
   #
   # Script: Name of script (what you named this file)
   # Author: Your Name (so I know who wrote it)
   #Date: (the date you wrote it)
   #Revision: 1.1.A(how many times it changed, and what
    state it is in(A, B, D, T or P)
     All scripts should also have A, B, D, T or P at the end of the
      revision statement so I know if it is Alpha, Beta, Dev, Test, or
      Production. All scripts turned in should be production scripts
 How to get your script to do more useful stuff
   If. Then
   if [test]
       Then
        stuff I want the computer to do
      fi
   If. Then. Else
      if [test]
        Then
           stuff I want the computer to do
        Else
           Stuff I want the computer to do if the first condition didn’t happen
        fi
 for
   for A=1
      do
           stuff I want the computer to do
         done

 While
   While A=1
     do
           stuff I want the computer to do
         done
 Until
   until A=1
      do
           stuff I want the computer to do
      done

 Case
   case A=1
      stuff I want the computer to do
   case A != 1
      stuff I want the computer to do
   easc

Más contenido relacionado

La actualidad más candente

Logrotate sh
Logrotate shLogrotate sh
Logrotate shBen Pope
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHwebelement
 
Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4Techvilla
 
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2Kazuho Oku
 
How to send files to remote server via ssh in php
How to send files to remote server via ssh in phpHow to send files to remote server via ssh in php
How to send files to remote server via ssh in phpAndolasoft Inc
 
Ansible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of PythonAnsible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of Pythontoddmowen
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X ServerYasuhiro Asaka
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationrjsmelo
 
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonbСтажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonbSmartTools
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on LinuxTushar B Kute
 
Any event intro
Any event introAny event intro
Any event introqiang
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingSteve Rhoades
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous Shmuel Fomberg
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Lingfei Kong
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersKirk Kimmel
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The AnswerIan Barber
 

La actualidad más candente (20)

Logrotate sh
Logrotate shLogrotate sh
Logrotate sh
 
Tomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSHTomáš Čorej - OpenSSH
Tomáš Čorej - OpenSSH
 
Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
 
Unix Programming with Perl 2
Unix Programming with Perl 2Unix Programming with Perl 2
Unix Programming with Perl 2
 
Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
How to send files to remote server via ssh in php
How to send files to remote server via ssh in phpHow to send files to remote server via ssh in php
How to send files to remote server via ssh in php
 
Ansible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of PythonAnsible, Simplicity, and the Zen of Python
Ansible, Simplicity, and the Zen of Python
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X Server
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your applicationRedis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
 
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonbСтажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
Стажировка 2016-07-27 02 Денис Нелюбин. PostgreSQL и jsonb
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
Any event intro
Any event introAny event intro
Any event intro
 
Multithreading in PHP
Multithreading in PHPMultithreading in PHP
Multithreading in PHP
 
Shell and perl scripting classes in mumbai
Shell and perl scripting classes in mumbaiShell and perl scripting classes in mumbai
Shell and perl scripting classes in mumbai
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 

Similar a Cis 216 – shell scripting

Similar a Cis 216 – shell scripting (20)

Unix
UnixUnix
Unix
 
Unit 10 investigating and managing
Unit 10 investigating and managingUnit 10 investigating and managing
Unit 10 investigating and managing
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Linux cheat sheet
Linux cheat sheetLinux cheat sheet
Linux cheat sheet
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Basic shell commands by Jeremy Sanders
Basic shell commands by Jeremy SandersBasic shell commands by Jeremy Sanders
Basic shell commands by Jeremy Sanders
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Learning Linux Series Administrator Commands.pptx
Learning Linux Series Administrator Commands.pptxLearning Linux Series Administrator Commands.pptx
Learning Linux Series Administrator Commands.pptx
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
 
Basic Linux day 1
Basic Linux day 1Basic Linux day 1
Basic Linux day 1
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Unix training session 3
Unix training   session 3Unix training   session 3
Unix training session 3
 
Linux day 1
Linux day 1Linux day 1
Linux day 1
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Lecture1 2 intro-unix
Lecture1 2 intro-unixLecture1 2 intro-unix
Lecture1 2 intro-unix
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
 
Unix2
Unix2Unix2
Unix2
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 

Más de Dan Morrill

Windows power shell and active directory
Windows power shell and active directoryWindows power shell and active directory
Windows power shell and active directoryDan Morrill
 
Understanding web site analytics
Understanding web site analyticsUnderstanding web site analytics
Understanding web site analyticsDan Morrill
 
Understanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUTUnderstanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUTDan 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
 
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
 

Más de Dan Morrill (16)

Windows power shell and active directory
Windows power shell and active directoryWindows power shell and active directory
Windows power shell and active directory
 
Understanding web site analytics
Understanding web site analyticsUnderstanding web site analytics
Understanding web site analytics
 
Understanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUTUnderstanding UNIX CASE and TPUT
Understanding UNIX CASE and TPUT
 
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
 
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

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Último (20)

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
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
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
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
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

Cis 216 – shell scripting

  • 1. Remembering the basics – Week 1 Dan Morrill April 01 2013
  • 2.  RMDIR – removes a directory only if it is empty  RMDIR –r – removes a directory regardless if it is empty or not  CHMOD 777 –r /user/dan – recursively changes the permissions of the directory /user/dan to RWXRWXRWX  grep – pattern matching for example ps –ef |grep apache2 will look for all processes running under the name apache2  egrep – used in regular expressions
  • 3.  find – find the location of a file (or files) on a hard drive at the command line  echo – writes data to the screen (standard output)  The TTY – Screen is always standard output (STDOUT)  more – displays the contents of a file one page at a time (hard for long files like syslog)  clear – clears the screen of text and provides the command prompt  chown – change the owner of a file or directory  rm – remove a file
  • 4.  mv – move a file to a new place and or new name  chgrp – change the group ownership of a file  mkdir – make a directory  ls – list the files in a directory, ls –la show the long form (including permissions and owners) of the files in a directory  cat – an alternative to showing the data in a file all at once  pwd – display the current directory  passwd – change the password of the currently logged in user
  • 5.  >> - append data to the END of a file  > - overwrites the file and any data in it  | - pipe character – strings commands together  || - logical OR – in that A || B in a loop, condition A or condition B  & - executes your process in the background – so you can still use the command line ./script.sh & will run your process in the background  && - Logical AND A && B if A succeeds, run B  sleep – stop execution of the script for a specified number of seconds sleep 20 means sleep for 20 seconds
  • 6.  diff – compares two files (this is great for seeing what changes were made in a script against the original and modified)  sdiff – only works with the 132 character display, but compares files side by side  lp – prints a file to the configured printer  lpstat – shows the user what is in the printer queue  ( ) – runs the enclosed command in a sub-shell  (( )) – evaluates and assigns a value to a variable and does math in a sub-shell
  • 7.  $(( )) – evaluates the enclosed expression  [ ] – test an expression to see if it is true or false  < > - used to compare values or strings  $( ) – command substitution – great when doing logical OR’s or AND’s
  • 8.  ++ - auto increment a value for I=1 ++ (takes I up by 1 for every loop)  -- - auto decrement a value for I=100 -- (takes I down by 1 for every loop)  <= - less than or equal to  >= - greater than or equal to
  • 9.  I will expect to see this in the header of every Unix Script you will turn in:  #!/bin/sh (tells the computer to use a bourne shell)  #  # Script: Name of script (what you named this file)  # Author: Your Name (so I know who wrote it)  #Date: (the date you wrote it)  #Revision: 1.1.A(how many times it changed, and what state it is in(A, B, D, T or P)  All scripts should also have A, B, D, T or P at the end of the revision statement so I know if it is Alpha, Beta, Dev, Test, or Production. All scripts turned in should be production scripts
  • 10.  How to get your script to do more useful stuff  If. Then  if [test]  Then  stuff I want the computer to do  fi  If. Then. Else  if [test]  Then  stuff I want the computer to do  Else  Stuff I want the computer to do if the first condition didn’t happen  fi
  • 11.  for  for A=1  do  stuff I want the computer to do  done  While  While A=1  do  stuff I want the computer to do  done
  • 12.  Until  until A=1  do  stuff I want the computer to do  done  Case  case A=1  stuff I want the computer to do  case A != 1  stuff I want the computer to do  easc