script command is used to record shell sessions.It is useful for documentation, capturing and replicating issues. Simplest Implementation: Now by default, output file is ‘typescript’. We can pass any other name for output file as below.$ script myscript.log Now myscript.log would contain the output.If we examine the contents of this file, we find exactly whatContinue reading “Record shell sessions”
Tag Archives: Shell Script
Shell Script to read csv file into Array
This is a shell script to read a csv file into array and display the contents. Using an array is preferred we can keep track of no. elements in a row.For example:echo ${row[@]} will display all the elements of array.echo ${#row[@]} will display the no. of elements in the array.Also to get the 2nd elementContinue reading “Shell Script to read csv file into Array”
Shell Script to compare row counts between two Greenplum Postgresql Database
This shell script takes 3 arguments: source db, target db and a list file of tables. List file is in format:$ cat listfile.lstschema.table : where<> ::schema2.table2 : where<> :: Also ~/gpdbinfo.dat file contains database name, host and port details. Below is the script to send the report file generated above as email :
Simple spin animation using shell script
Below shell script will do a simple animation of rotating “pipe” (|) . We use an array called spinner, with elements : ( ‘|’ ‘/’ “–” ‘\’ ). We loop through the elements each 0.1 secs to make it look like the rotating animation.