To get a single string in output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To get a single string in output
# 8  
Old 01-30-2018
Or alternatively use a regex string:
Code:
sub ( "[^/]*/", X, $i )
sub ( "/", X, $i )

# 9  
Old 01-31-2018
Quote:
Originally Posted by Yoda
Ok, escape it:-
Code:
sub ( /[^\/]*\//, X, $i )

Thanks Yoda,
i have added the header also to the script you provided, it is working fine, but I am expecting to get the header over those rows for which the URL or port changes. URL will remain same for few rows and then it change, and once the URL change the header should come,
like in below input you can see the 3 record URL changed.so the header should populate over the third record(validate only server and port )

Code:
INPUT FILE:
SKILLED LANGUAGE - ENTER CREDENTIALS,You do not have skills or languages,http://xxx:7003/abc/protected/home.xhtml

NOT KNOWN - NEW VALUE,You do not have skills or languages,http://xxx:7003/abc/protected/home.xhtml
SKILLED LANGUAGE - ENTER CREDENTIALS,You do not have skills or languages,http://xxx:7005/abc/protected/home.xhtml

Code:
nawk -F, '
        BEGIN {
	        print "<html>"
                print "<body>"
                print "<table border=3>"        
                                print "<tr bgcolor=#85C1E9>"
                                print "<th>FUNCATIONALITY</th>"
                                print "<th>ERROR</th>"
                                print "<th>URL</th>"
                                print "</tr>"
        }
        {
                print "<tr>"
                for ( i = 1; i <= NF; i++ )
                {
                        if ( i == 2 )
                        {
                                sub ( /[^\/]*\//, X, $i )
                                sub ( /\//, X, $i )
                        }
                        print "<td>" $i "</td>"
                }
                print "</tr>"
        }
        END {
                print "</table>"
                print "</body>"
                print "</html>"
        }
                ' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Single grep to multiple strings with separate output per string

I need to grep multiple strings from a particular file. I found the use of egrep "String1|String2|String3" file.txt | wc-l Now what I'm really after is that I need to separate word count per each string found. I am trying to keep it to use the grep only 1 time. Can you guys help ? ... (9 Replies)
Discussion started by: nms
9 Replies

2. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

3. Shell Programming and Scripting

Output to single line

Hi, I am using below command and getting below output. echo "dis ql(*) CLUSTER"|runmqsc CT.QM.ASSA10T1| egrep 'QUEUE|CLUSTER'|egrep -v 'SYSTEM|XMITQ'| sed -e 's/QUEUE(/ /g' -e 's/TYPE(QLOCAL)/ /g' -e 's/CLUSTER(/ /g' -e 's/)/ /g' output CT.CL.ALLUHUB.FLST_TO_HUB_PROV.01... (20 Replies)
Discussion started by: darling
20 Replies

4. Shell Programming and Scripting

Output to be in single line

Hi All, Small script but :wall:, please help in this regard. for i in 1 2 3 do echo $i done result : 1 2 3 I want the above to be printed as below expected result: 1 2 3 Thanks in advance :) (3 Replies)
Discussion started by: girish_satyam
3 Replies

5. Shell Programming and Scripting

How to select a single string

I am learning sed/awk. So, bear with me. I have successfully created a list (based on sed) which looks like: <cl:item href="clsysrev/XTT004/XTT05064.xml" productSubtitle="animals" unitStatus="today"IR"> <cl:item href="clsysrev/XTT007/XTT08581.xml" productSubtitle="humans"... (3 Replies)
Discussion started by: alonso_canada
3 Replies

6. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

7. Shell Programming and Scripting

awk: round output or delimit output of arithmatic string

I have a file with the following content. > cat /tmp/internetusage.txt 6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file. awk '{ print $1/$2*100 }' /tmp/internetusage.txt This outputs the value "22.3643" as a... (1 Reply)
Discussion started by: jelloir
1 Replies

8. Shell Programming and Scripting

How to print the output in single line

Hi, Please suggest, how to get the output of below script in single line, its giving me in different lines ______________________ #!/bin/ksh export Path="/abc/def/ghi"; Home="/home/psingh/prat"; cd $Path; find $Path -name "*.C#*" -newer "abc.C#1234" -print > $Home cat $Home | while... (1 Reply)
Discussion started by: Prat007
1 Replies

9. AIX

ls command output in single line

Hi, Can anyone suggest me how can I display the output of ls command in single line with some delimiter say pipe (|)? I know it can be done by writing a script by using the loops but I wanted to know are there any other single line commands? Thanks for your help Sheshadri (7 Replies)
Discussion started by: arsheshadri
7 Replies

10. Shell Programming and Scripting

Need output in different lines not in one single line

I am getting the coutput like this as show below in one single line, where as the command is executed is several lines and the output should also be requied in several lines, not in one single line. Anyone any idea? p4 opened -a | grep *locked* | awk '{ printf $8 }' >/tmp/aa $ cat... (1 Reply)
Discussion started by: csaha
1 Replies
Login or Register to Ask a Question