Skip to main content

Posts

Showing posts with the label Shell

Working with Git from Existing Repo to New Repo

 git clone existing repo in IDE  git clone https://github.com/org/repo.git make necessary changes in the files  git remote -v it list all the remote urls in the local system IDE origin https://github.com/org/repo.git (fetch) origin https://github.com/org/repo.git (push) git rename existing origin url to new old-orign git remote rename origin old-origin git add new repo url to origin git remote add origin https://github.com/org/repo2.git verify origin urls git remote -v should get 4 urls 2 for old-origin(old repo) and 2 for (new repo) origin  git reinitialize  git init .   Reinitialized existing Git repository in C:/repo/.git/ git add all files git add . commit the changes  git commit -m "Initial" git remove .idea files  git rm -r --cached .idea  removes already tracked files in git rm -r .idea  this deletes all .idea files including the folder locally git push -u origin --all git remote remove old-origin

CSV to HTML Converter Shell Script

#Generic Converter from CSV to HTML #!/bin/bash usage () { cat <<EOF Usage:$(basename $0)[OPTIONS] input_file > ouptut.html Explicit Delimiter can be specified if not then it default to comma as delimiter Options: -d specify delimiter , instead of comma --head specified then treats first line as column header , <thead> and <th> tags --foot last line , <tfoot> and <th> tags Samples: 1.$(basename $0) input.csv Parse 'input.csv' with comma as delimiter and send HTML table to STDOUT 2. $(basename $0) -d '|' < input.csv > out.html Parse 'input.csv' with PIPE as delimiter and send HTML table to out.html 3. $(basename $0) -d '\t' --head --foot < input.tsv > out.html Parse 'input.tsv' , tab as delimiter process first and last lines as header and footer write to out.html ...

Generating HTML Report From Hive and Sending thru Email

Script to Generate HTML Rpt #!/bin/ksh TODAY = `date +'%Y %b %d'` rm file.csv rm report.html #Hive Query to Fetch Results from Hive Table hive -S -e "SELECT COLA,COLB FROM hive_tbl;" > file.csv #Convert the Results to Comma Separated sed - i 's/\t/,/g' file.csv #awk command to parse the file #recCNT=`awk -F ',' '{print $1}' file.csv #Converting CSV File to HTML echo "<HTML><BODY>" > report.html echo "<h2><font color=blue>Report Header</font></h2>" >> report.html #loop through records in CSV and Convert to Table awk 'BEGIN{ FS="," print "<TABLE border="1"><TH><font color=brown><center> COLA HEADER</center></font></TH><TH><font color=b...