Bash script

  • View
    170

  • Download
    5

Embed Size (px)

DESCRIPTION

introduction to bash script

Text of Bash script

  • 1. Bash Script

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. Lets explore Bash Script 4. 1.Variables 5. Global vs. Local variables 6. 2.Conditional statements and loops 7. A.Conditional statements 8. If/else 9. Elif 10. Arithmetic Comparisons 11. Case 12. b.Loops 13. While 14. For(with numbers) 15. For(with directories) 16. For(with arrays) 17. Until 18. 3.Bash functions 19. Syntax to create a bash function: 20. Function with arguments 21. Functions with returned values 22. 4.String manipulations 23. a.String length 24. b.Substring extraction 25. c.Shortest Substring Match 26. d.Find and Replace String Values 27. e.Replace all the matches 28. f.Replace beginning and end 29. f.Replace beginning and end 30. 5.I/O Redirection 31. a.Standard Output > 32. a.Standard Output > 33. b.Standard Input < 34. b.Standard Input < 35. c.Pipes | 36. 6.Special commands 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. b.Find Is used to fined files based on specific criteria. Syntax: find -name search by name -perm search by access rihghts on file, -user search by files owner, -group search by files group, 39. c.Awk Is used to print specific lines and columns from a file, with conditions. Syntax : awk '{print $NF}' file 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. e.Alias Is used to enable a replacement of a command by another string Syntax : alias myalias=command_name 42. Thank you for your attention