Print a tabular report using shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print a tabular report using shell
# 1  
Old 01-12-2016
Tools Print a tabular report using shell

Hi All,

I am trying to write a shell script which shows the report like a table with below details:

Branch Name:
FileName changed| Author | revision number of the file

1)we use SVN as our version control tool, so our intention is to use svn commands and generate a basic report and then use shell script to neatly organize it.I am unable to align the output as a table. I used a bit perl, but i want everything in shell.


Code:
#!/usr/local/bin/perl
require "List/MoreUtils.pm";
use strict;
use List::MoreUtils qw(:all);


my @FilePath=`svn log RepoUrl -v -q | awk '/paths/ { getline; print $1 }'| awk -F' ' '{print \$2}'|awk -F'/' '{print \$NF}'`;
my @Author=`svn log RepoUrl -q | awk -F'|' '{print \$2}'| awk 'NF' `;
my @Revision=`svn log RepoUrl -q | awk -F'|' '{print \$1}'| sed 's/'-'//g'| awk 'NF' `;
my $branch=`svn info RepoUrl | grep ^URL | awk -F'/' '{print \$NF}'`;


printf  "                                     Branch : $branch                                                                          \n";
printf  "|========================================================================================================================================|\n";
printf  "| %-35s | %-35s | %-35s \n","   FILENAME   ", "  AUTHOR  ","  VERSION  ";
printf  "|========================================================================================================================================|\n";

my $result = each_array(@FilePath, @Author, @Revision);

while ( my ($a, $b, $c) = $result->() )
{

printf  "$a"."\t"."$b"."\t"."$c";

}

printf  "|========================================================================================================================================|\n";


Expected result:

					Branch Name: release_1
	FileName Changed|   Author      |   Revision Number of file changed|
     hello1.c        |   saketh1     |   r120
	 hello2.c        |   saketh2     |   r12
	 hello3.c        |   saketh3     |   r100

Current/ERROR OUTPUT:

                     Branch Name: release_1
	FileName Changed|   Author      |   Revision Number of file changed|
     hello1.c
	 | saketh1
	 |  r120
	 hello2.c
	 | saketh2
	 |  r12
	 hello1.c
	 | saketh3
	 |  r100

# 2  
Old 01-12-2016
it is not shell, but perl.

Code:
perldoc -f chomp

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To have a mail in tabular format

Hello Guys, developing a monitoring shell script to have my queue depth count over mail . here is the sample input file to the script which has all the queue names 1 : DISPLAY QUEUE(*) WHERE (CURDEPTH GT 0) ZFC8409: Display Queue details. QUEUE(QL.GVR.ATA.CACHE.01) ... (10 Replies)
Discussion started by: wims
10 Replies

2. Shell Programming and Scripting

Dispaying output in tabular form

hi, I have a script which is dispaying the output as below: Column 3:value1 Column 4:value 4 column 8:value 8 column 9:value 9 column 13:value 13 Column 3:value10 Column 4:value 40 column 8:value 80 column 9:value 90 column 13:value 103 However,I need the output in tabular... (5 Replies)
Discussion started by: Vivekit82
5 Replies

3. UNIX for Dummies Questions & Answers

Put data in tabular form..

Dear Friends, I have a file as under : +++ ME 12-06-13 18:16:20 A RED FEW AND ROW1 1MN FEL AS HI FI BV LR TS HR ES MR * 0 13296 0 120 1 15 KS RR 10 0 +++ ME 12-06-13 18:26:20 A RED FEW AND ROW2 1MN FEL AS... (2 Replies)
Discussion started by: vanand420
2 Replies

4. UNIX for Dummies Questions & Answers

Put data into tabular form

Hi I am having a file which is required to be presented in the under-noted output form. Please suggest. Input: Kapil: apple 4 banana 6 cherry 0 Manoj: apple 13 banana cheery 2 Output: apple banana cherry Kapil: 4 6 0 Manoj: 13 2 Thanks in... (4 Replies)
Discussion started by: vanand420
4 Replies

5. Shell Programming and Scripting

Tabular form in shell script

hi, I need to mention the data in tabular form in shell script. :confused: Input as below: Health check (heading1) CPU/Memory Utilization of pc on server (h2) 1214 of rpc3 is exceeds 0.3 % (data) CPU Utilization is normal for rpc/33 on 2673 CPU Utilization is normal for rpc/33 on... (2 Replies)
Discussion started by: sreelu
2 Replies

6. Shell Programming and Scripting

generate tabular output from an input text file in unix shell scripting

Hi, I have the output (as below) which i want it to be in a table. For e.g. space utilization in PSE on path /logs is 0% space utilization in PSE on path /logs/tuxedo/tuxlsp is 16% space utilization in PSE on path /ldvarlsp/lsp/log is 37% space utilization in PSE on path /home is 6%... (7 Replies)
Discussion started by: pkbond
7 Replies

7. UNIX for Dummies Questions & Answers

How to read tabular data?

Hello, I have a log file which contains data in tabular format(3 columns(total, posted, rejected) and 2 rows(close, total)) as below. TOTAL POSTED REJECTED CLOSE 3 3 0 TOTAL 3 3 0 I have to search for all Total... (1 Reply)
Discussion started by: akash028
1 Replies

8. UNIX for Dummies Questions & Answers

Linux Shell Question: how to print the shell script name ?

Suppose I have a script named "sc.sh" in the script how to print out its name "sc.sh"? (3 Replies)
Discussion started by: meili100
3 Replies

9. Shell Programming and Scripting

help to print report

As I'm a newbie to UNIX, very newbie in fact, could anyone help me to write shell script . I need to generate fail logs for my testsuite . I have to print total no of fails sort by product ,host and version of software. The product name is stored in different file. The fails are stored in... (0 Replies)
Discussion started by: dolly83
0 Replies

10. HP-UX

how to print part of report ?

HellO. I need small help, daily am printing one report witch contain Dynamic Data changed daily, more or less, What I need is just to print this Changing data because the rest of report is Huge and we lost a lot of paper because of that Example of what I need to print Bank ******... (2 Replies)
Discussion started by: Golive
2 Replies
Login or Register to Ask a Question