how to add more number in comment section D0000,S0000,D0000,D12345,S12345 |


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to add more number in comment section D0000,S0000,D0000,D12345,S12345 |
# 1  
Old 10-10-2011
how to add more number in comment section D0000,S0000,D0000,D12345,S12345 |

Code:
#!/bin/bash
repository=$1;
txn=$2;
#echo -e "\n\npre-hook Script called\n\n";
logmsg=$(svnlook log ${repository} -t ${txn});
logmsg_vals="${logmsg%%|*}|";
logmsg_char="${logmsg_vals:0:1}";
logmsg_len=$(echo ${logmsg} | cut -d' ' -f1);           #
logmsg_len2=$(echo ${logmsg} | awk '{print $2}');       #
#logmsg_len="${logmsg%%|*}";
logmsg_suffix="|";

#echo -------------
#echo "message=$logmsg:char=$logmsg_char:value=$logmsg_len:length=${#logmsg_len}:len2=$logmsg_len2:suffix=$logmsg_suffix" >&2;
#echo -------------
#echo -e "\n $logmsg \n ${logmsg:0:1}"
  if [[ $logmsg_char == "D" || $logmsg_char == "S" ]]; then
        if  [[ "${#logmsg_len}" -le "6" ]]; then
            if [[  "${logmsg_len2}" != "${logmsg_suffix}" ]]; then
                 echo -e "\nERROR - Comment:\n\tDefect|Story number should be seperated by a PIPE character.\n\tEx: \"<D/S>12345 | <description>\"\n\nYour Comment:\n\t\"$logmsg\"\n" >&2;
                 exit 1;
            else
                echo -e "\nSuccess\n" >&2;
                exit 0;
            fi
        else
            echo -e "\nERROR - Comment:\n\tDefect|Story number (including \"D\" or \"S\" character) should be 6 chars max, excluding PIPE (\"|\") character\n\tEx. \"<D|S>12345 | <description>\"\n\nYour Comment:\n\t\"$logmsg\"\n" >&2;
#            echo -e "Your Comment:\n\t$logmsg\n" >&2;
            exit 1;
        fi
  else
     echo  -e "\nERROR - Comment:\n\tDefect|Story number that should start with either \"D\" or \"S\" character\n\tEx. \"<D|S>12345 | <description>\"\n\nYour Comment:\n\t\"$logmsg\"\n" >&2;
#     echo -e "Your Comment:\n\t\"$logmsg\"\n" >&2;
     exit 1;
  fi




Question is

This is pre-commit shell script in svn to check this comment section "D0000 | KestrelPrdV2_0.build.177 - svn 141115 tag as V2.0.0.14" and this script
fullfill the three conditions currently.
1)It shoud be started with D or S(e.g.:D0000)
2)It should not be max than 6 characters i.e. equal and less than 6
3) there should be | symbol (e.g. D0000 | )
so basically this script is checking the left part of the comment section till | symbol .i.e the comment section should be insert by the user with these three conditions
Now I want one more thing here that is I want to add the comment "D0000,S0000,D0000,D12345,S12345 | KestrelPrdV2_0.build.177 - svn 141115 tag as V2.0.0.14"

all the three conditions should be fulfil but I want that I could add more numbers in the lesft part D0000,S0000,D0000,D12345,S12345 upto infinity but with all below three conditions
1)It shoud be started with D or S(e.g.:D0000)
2)It should not be max than 6 characters i.e. equal and less than 6
3) there should be | symbol (e.g. D0000 | ) after entering all numbers e.g. D0000,S0000,D0000,D12345,S12345 | and also it should be sperated with comma given in the example.
# 2  
Old 10-11-2011
Can someone help me on this?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add comment on last line if found match

Hi All, totally new on it , normally use it for just 1 line. i'm looking for help. i'm have 2 file. file 1 : -------------------------------------------------- c12 c1 c3 -------------------------------------------------- file 2: other content ... (10 Replies)
Discussion started by: kttan
10 Replies

2. Shell Programming and Scripting

Add comment if not present

I have a file cat /root/file #import node1 #import node2 import node2 import node4 After sed/awk operation the file should be as follows cat /root/file #import node1 #import node2 #import node2 #import node4 (6 Replies)
Discussion started by: anil510
6 Replies

3. Shell Programming and Scripting

How can i comment out a section between two particular lines

I want to find out which files under /etc have the the following section: and then i would like to comment out the above section in all the files. Please help. (3 Replies)
Discussion started by: proactiveaditya
3 Replies

4. Shell Programming and Scripting

add line and remove comment in some script

Hi, i need some help. i am not sure about my idea. I have a script directory under my home directory,which has a lot of scripts in it. These are some names of the scripts in /axxhome/prdv/script aly300.sh axt300.sh arv300.sh clp300.sh ctth300.sh aly400.sh axt400.sh arv400.sh... (6 Replies)
Discussion started by: debu000
6 Replies

5. Shell Programming and Scripting

Parse configuration file & add line in particular section

Greetings, I recently built a replicated DRBD, Heartbeat, & iSCSI Target Initiator storage server on Ubuntu 10.04 to offer shared storage to server Vmware ESX and Microsoft Clusters. Everything works flawlessly, however I wanted to make a script to create, remove, grow volumes to offer ESX... (6 Replies)
Discussion started by: Aeudian
6 Replies

6. Shell Programming and Scripting

Extract section of file based on word in section

I have a list of Servers in no particular order as follows: virtualMachines="IIBSBS IIBVICDMS01 IIBVICMA01"And I am generating some output from a pre-existing script that gives me the following (this is a sample output selection). 9/17/2010 8:00:05 PM: Normal backup using VDRBACKUPS... (2 Replies)
Discussion started by: jelloir
2 Replies

7. Shell Programming and Scripting

how to add the number of row and count number of rows

Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count The input file: 21 2341 A 21 2341 A 21 2341 A 21 2341 C 21 2341 C 21 2341 C 21 2341 C 21 4567 A 21 4567 A 21 4567 C ... (6 Replies)
Discussion started by: juelillo
6 Replies

8. Shell Programming and Scripting

sed/awk to insert comment at defined line number

Hi there, may someone easily help me on this : I want to insert a text in a specific line number like : linenumb2start=`cat memory_map.dld | nl -ba | egrep -i "label" | cut -f1` line2insert=`expr $linenumb2start + 2` and now I need to replace something like {} with {comment} at... (8 Replies)
Discussion started by: homefp
8 Replies

9. Shell Programming and Scripting

Need to add a comment line in a text file

Hi I need to add a comment line at the begining of a text file. The scenario is given below. 1. The number of servers that needs to be updated is around 80 2. The location of the text file in all the servers are the same including the file name. 3. The comment has to be added at the very... (2 Replies)
Discussion started by: orakhan
2 Replies
Login or Register to Ask a Question