You are previewing Linux and Unix Shell Programming.
O'Reilly logo
Linux and Unix Shell Programming

Book Description

Learn how to create and develop shell scripts in a step-by-step manner increasing your knowledge as you progress through the book. Learn how to work the shell commands so you can be more productive and save you time.

Table of Contents

  1. Copyright
  2. Acknowledgements
  3. Introduction
  4. The shell
    1. File security and permissions
      1. Files
      2. Types of files
      3. Permissions
      4. Changing permission bits
      5. Directories
      6. Set-uid
      7. chown and chgrp
      8. umask
      9. Symbolic (soft) links
      10. Conclusion
    2. Using find and xargs
      1. find options
      2. Xargs
      3. Conclusion
    3. Running commands unattended
      1. Cron and crontab
      2. The at command
      3. The & command
      4. The nohup command
      5. Conclusion
    4. Filename substitution
      1. Using the *
      2. Using the ?
      3. Using [ . . . ] and [ ! . . . ]
      4. Conclusion
    5. Shell input and output
      1. echo
      2. read
      3. cat
      4. Pipes
      5. tee
      6. Standard input, output and errors
      7. File redirection
      8. Combining standard output and error
      9. Merging standard output and standard error
      10. exec
      11. Using file descriptors
      12. Conclusion
    6. Command execution order
      1. Using &&
      2. Using ||
      3. Grouping commands using () and {}
      4. Conclusion
  5. Text filtering
    1. Introducing regular expressions
      1. Matching a single character with a period
      2. Matching a string or character at the beginning of a line with a ^
      3. Matching a string or character at the end of a line with $
      4. Matching a single or string of characters with *
      5. Escaping the meaning of a special character using \
      6. Matching ranges or sets using []
      7. Matching a specific number of occurrences with \{ \}
      8. Conclusion
    2. The grep family
      1. grep
      2. grep and regular expressions
      3. Class names
      4. grep on the system
      5. egrep
      6. Conclusion
    3. Introducing awk
      1. Calling awk
      2. awk script
      3. Conclusion
    4. Using sed
      1. How sed reads data
      2. Calling sed
      3. sed and regular expressions
      4. Basic sed editing examples
      5. Modifying strings with substitute (&)
      6. Writing to a file within sed
      7. Reading text from a file
      8. Quitting after a match
      9. Displaying control characters in a file
      10. Using sed on the system
      11. Quick one-liners
      12. Conclusion
    5. Merge and divide
      1. Using sort
      2. sort on the system
      3. Using uniq
      4. Using join
      5. Using cut
      6. Using paste
      7. Using split
      8. Conclusion
    6. Using tr
      1. About tr
      2. Conclusion
  6. The login environment
    1. The login environment
      1. The /etc/profile
      2. Your $HOME .profile
      3. Using stty
      4. Creating a .logout file
      5. Conclusion
    2. Environment and shell variables
      1. What is a shell variable?
      2. Local variables
      3. Environment variables
      4. Positional variable parameters
      5. Conclusion
    3. Quoting
      1. The need for quoting
      2. Double quotes
      3. Single quotes
      4. Back quote
      5. Backslash
      6. Conclusion
  7. Basic shell programming
    1. Introduction to shell scripts
      1. Reasons for using a shell script
      2. What a script contains
      3. Running a script
      4. Conclusion
    2. Conditional testing
      1. Testing for a file status
      2. Using logical operators with tests
      3. Testing strings
      4. Testing numbers
      5. Using expr
      6. Conclusion
    3. Control flow structures
      1. Exit statuses
      2. Control structures
      3. if then else statements
      4. Case statement
      5. for loop
      6. until loop
      7. while loop
      8. Controlling loops using break and continue
      9. Menus
      10. Conclusion
    4. Shell functions
      1. Declaring functions in a script
      2. Using functions in a script
      3. Passing parameters to a function
      4. Returning from a called function
      5. Testing the values returned by a function
      6. Using functions in the shell
      7. Creating a function file
      8. Sourcing the file
      9. Checking the loaded functions
      10. Executing shell functions
      11. Calling functions
      12. Sourcing files is not only for functions
      13. Conclusion
    5. Passing parameters to scripts
      1. The shift command
      2. getopts
      3. Conclusion
    6. Creating screen output
      1. tput
      2. Using tput
      3. Conclusion
    7. Creating screen input
      1. Adding records
      2. Deleting records
      3. Amending records
      4. Viewing records
      5. Conclusion
    8. Debugging scripts
      1. Common errors
      2. The set command
      3. Conclusion
    9. Shell built-in commands
      1. Complete list of shell built-in commands
      2. Conclusion
  8. Better scripting skills
    1. Going further with here documents
      1. Creating a quick file
      2. Creating a quick print document
      3. Automating menus
      4. Automating ftp transfers
      5. Accessing databases
      6. Conclusion
    2. Shell utilities
      1. Creating hold files
      2. Signals
      3. trap
      4. eval
      5. logger command
      6. Conclusion
    3. A small collection of scripts
      1. pingall
      2. backup_gen
      3. del.lines
      4. access.deny
      5. logroll
      6. nfsdown
      7. Conclusion
    4. Run level scripts
      1. How can you tell if you have run level directories?
      2. Finding out your current run level
      3. Bringing you up to speed on inittab
      4. Now for the run levels
      5. Using inittab to launch applications
      6. Other methods of starting and shutting down services
      7. Conclusion
    5. cgi scripts
      1. What is a Web page?
      2. cgi
      3. Connecting to a Web server
      4. cgi and HTM script
      5. Introducing the get and post methods
      6. Conclusion
  9. ASCII chart
  10. Useful shell commands
    1. basename
    2. cat
    3. compress
    4. cp
    5. diff
    6. dircmp
    7. dirname
    8. du
    9. file
    10. fuser
    11. head
    12. logname
    13. mkdir
    14. more
    15. nl
    16. printf
    17. pwd
    18. rm
    19. rmdir
    20. script
    21. shutdown
    22. sleep
    23. strings
    24. touch
    25. tty
    26. uname
    27. uncompress
    28. wait
    29. wc
    30. whereis
    31. who