Bash script

482 views

Published on

introduction to bash script

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
482
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
20
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Bash script

  1. 1. Bash Script
  2. 2. • Bash is a Unix shell written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell . • Released in 1989,it has been distributed widely as the shell for the GNU operating system and as a default shell on Linux and Mac OS X.
  3. 3. Let’s explore Bash Script…
  4. 4. 1.Variables
  5. 5. Global vs. Local variables
  6. 6. 2.Conditional statements and loops
  7. 7. A.Conditional statements
  8. 8. If/else
  9. 9. Elif
  10. 10. Arithmetic Comparisons
  11. 11. Case
  12. 12. b.Loops
  13. 13. While
  14. 14. For(with numbers)
  15. 15. For(with directories)
  16. 16. For(with arrays)
  17. 17. Until
  18. 18. 3.Bash functions
  19. 19. Syntax to create a bash function:
  20. 20. Function with arguments
  21. 21. Functions with returned values
  22. 22. 4.String manipulations
  23. 23. a.String length
  24. 24. b.Substring extraction
  25. 25. c.Shortest Substring Match
  26. 26. d.Find and Replace String Values
  27. 27. e.Replace all the matches
  28. 28. f.Replace beginning and end
  29. 29. f.Replace beginning and end
  30. 30. 5.I/O Redirection
  31. 31. a.Standard Output “>”
  32. 32. a.Standard Output “>”
  33. 33. b.Standard Input “<“
  34. 34. b.Standard Input “<“
  35. 35. c.Pipes “|”
  36. 36. 6.Special commands
  37. 37. a.Grep • Is used to search a characters chain within a file • -v displays the lines that do not contain the string • -c count the number of lines containing the string • -n each line containing the string is numbered • -x the line that exactly matches the string • -l displays the names of files that contain the string
  38. 38. b.Find • Is used to fined files based on specific criteria. • Syntax: find <folder> <search criteria> • -name search by name • -perm search by access rihghts on file, • -user search by file’s owner, • -group search by file’s group,
  39. 39. c.Awk • Is used to print specific lines and columns from a file, with conditions. • Syntax : awk '{print $NF}' file
  40. 40. d.Sed • The SED UNIX Command in Linux enables you to work with the text inside your files and can be used to perform different functions to it. • Syntax :
  41. 41. e.Alias • Is used to enable a replacement of a command by another string • Syntax : alias myalias=“command_name”
  42. 42. Thank you for your attention

×