I have the similar lines of text spread across my Jenkins Console out put:
NumberOfTestCases of tier1 in https://****:****@bess-bitbucket.bearingpoint.com/scm/bnktst/stat-autopilot-testcases.git are 4
I wanted to extract the following into 3 columns:
TIER | URL | NumberOfTestCases |
---|---|---|
tier1 | https://:@bess-bitbucket.bearingpoint.com/scm/bnktst/stat-autopilot-testcases.git | 4 |
I have the following code which is extracting only the URl and NumberofTestCases. I wanted to get the first column values as well included in my SED command.
wget ${BUILD_URL}/consoleText -O ${WORKSPACE}/SomeFile.txt
sed -n 's/.*\(https.*git\)\ are\ \([[:digit:]]\{1,\}\)/\1,\2/p' SomeFilex.Txt
CodePudding user response:
Using sed
$ sed -En '/NumberOfTestCases/s/[^ ]* ([^ ]* ){2}([^ ]*) [^ ]* ([^ ]*).*([0-9] )/\2\t\3\t\4/p;1i TIER\tURL\tNumberOfTestCases' somefile.txt
TIER URL NumberOfTestCases
tier1 https://****:****@bess-bitbucket.bearingpoint.com/scm/bnktst/stat-autopilot-testcases.git 4