Click here to start

Table of contents

Author: Abdolreza Ghods, Department of Earth Sciences, Institute for Advanced Studies in Basic Sciences, Zanjan, Iran

E-mail: aghods@iasbs.ac.ir

Homepage: http://www.iasbs.ac.ir/~aghods

Further information:

         

Bash Programming for Geophysicists Why Bash Scripting What is bash programming? Step 1: Simple Linux commands Quick statistic for files in a data bank Example 1-1: Make a list of files ls Example 1-2: ls and wild cards BHRC Data Example 1-2 continued Example 1-2 continued Example 1-3: Sorting files in terms of size Example 1-3 continued Example 1-4: Sorting files in terms of their modification time Example 1-5: Size of files du Example 1-6: Copying files cp Example 1-7: Erasing files rm Example 1-7: Erasing a directory rm Example 1-8: Moving files or directories mv Linux File System Linux File System continued File Permission in Linux File permissions in Linux ... Example 1-9: Changing permission of a file or directory chmod Example 1-10: Changing ownership of a file or directory chmod EXample 1-11: Display current Linux tasks top Example 1-11 top output Example 1-12: Display file system disk space usage df Example 1-13: Display who is logged on a system who Example 1-14: Connecting to other computers ssh Example 1-14: ssh continued Example 1-15: Copying to other computers scp Example 1-16 Display the on-line manual pages man Example 1-17: Finding files locate and find Example 1-18: Packing and unpacking files tar Example 1-19: Compressing files gzip, gunzip Other useful Linux commands Exercise 1 Step 2: Combining several Linux commands The grep command: Find a word within a large file Example 2-1: The grep command Example 2-2: The wc command Example 2-3: Redirection > Example 2-3: continued Redirection >> Example 2-4: Piping | Example 2-5: Running job in the background nohup Example 2-5: continued nohup Example 2-5: continued nohup and matlab Example 2-6: Changing Priority nice Example 2-7: Measuring execution time of your program! Exercise 2 Step 3: The powerful awk command The awk command Example 3-1: awk command: Printing selected number of columns Example 3-2: awk command, ignoring header lines Example 3-3: awk command, the substr facility Example 3-4: awk commanf, if and awk Example 3-4: awk command, continued if and awk Example 3-4: awk command, internal variables Example 3-5: awk command, calculations and formatted print Slide 60 Step 4: Bash Scripting How to make a simple bash script Example 4-1: Running several tasks consequentially Example 4-2    Automation using Do loops Example 4-2:example4_2_number_dir.bash About IRSC seismic waveforms Example 4-3: Automation using sort and uniq Example 4-3 :Automation using sort and uniq: Example Example 4-4: Automation using for and while Example 4-4: iiees_tree.bash Example 4-5: Automation using external bash variables Example 4-5 insn.tree_1.bash Example 4-5 insn.tree_2.bash Example 4-6: Automation and if Example 4-6 insn.tree_3.bash Hints for debugging a bash program Exercise 4 Step 5: Advanced examples Example 5-1: Extracting data from a big seismic data bank Example 5-2: Managing IRSC zipped waveforms files Example 5-3: Converting format of a large number of waveforms Example 5-4: Running a given program with different inputs Example 5-5: Runing programs using parallel stratedgy End!