Monday, May 30, 2022

Shell Scripting

 

  1. Basic Information
  2. Check Shells
  3. Sample Hello Script (Echo Commands Options)
  4. re-direct to output into file
  5. creating file and adding the data while executing script
  6. adding new data instead of replacing
  7. Comments
  8. quotes
  9. HereDOC -- What ever we are going to write in scrpit: it will visible on output
  10. Script Inputs ( Arguments, Read, STDIN)
  11. Script Outputs (STDOUT , STDERR)
  12. Variables
  13. Command Arguments
  14. Example Script1 ( Echo, variables, arguments)
  15. Ex : Create no of files
  16. Ex: Send output from one script to another script
  17. Arithmetic Operators
  18. File Operators for finding (-f, -d, -s, -w, -r, -x)
  19. Ex: Numeric and Athematic Operations : Arithmetic Operations
  20. Ex: Numeric and Athematic Operations: converting-list-of-hexadecimal-numbers
  21. Test Commands (integral part of the conditional statements)
  22. Functions
  23. Conditional Statements (IF, if-else, if-else-if, case)
  24. Loop Statements (For, While, Until)
  25. Conditional Statements (Example)
  26. Conditional / Loop Examples
  27. Loop Statement Ex: Get all test files size and Move 0KB files into separate folder
  28. Break & Continue statements
  29. String Processing - comparing strings
  30. String Processing - Comparing Length of strings
  31. String Processing - String concatenation
  32. String Processing - script for upper and lower cases
  33. Grep(global regular expression print) : Search string in the File : Example 1
  34. Grep : Search string in the File from given path : Example 2
  35. Grep : Case Sensitive (-i)
  36. Grep : Case sensitive & For Line Numbers (-n)
  37. Grep : count of lines which is contains the given text (-c)
  38. Grep : count of lines which is not contains the given text(-v)
  39. Grep : Display's the lines after the results( -A, -B, -C)
  40. AWK : print a file
  41. AWK : search for a specific pattern using ‘awk’
  42. AWK : extract the content from the lines, where the program found its targeted word.($1, $2)
  43. AWK : To print the first item along with the row number(NR) separated with ” – “ from each line
  44. AWK : To print any non empty line if present
  45. AWK: To print the squares of first numbers from 1 to n say 6:
  46. AWK: To find/check for any string in any specific column:
  47. AWK: Printing lines with less than 20 characters:  
  48. AWK: To find the length of the longest line present in the file:
  49. SED - Stream editor - Changing one letter --> 's/i/I/'
  50. SED - Changing all letters --> 's/i/I/g' --> Global Replacement
  51. SED - Substitute word
  52. SED - Case Sensitive (-i)
  53. SED - Removing lines /d
  54. SED - Displaying multiple consecutive lines--------->>sed -n '1p' <filename>
  55. SED - Reading Commands From another File--------->>sed -f <sed file> <file name> 
  56. SED - Replacing words in selective lines->> '1,3s/word/relaceword/'
  57. SED - Replacing selective occurrence (sed 's/unix/25555/4i' $fileName )
  58. SED - Printing lines that contain a particular word (sed -n '/WIndows/p')
  59. SED - Transformation of Characters----------->>>'y/abc/123/'
  60. SED - To delete any blank records- awk -F " " '{print $4}' | sed '/^$/d'
  61. SED All Commands


=========================================================================
Some More Example Scripts
=========================================================================