Need to cut a specific pattern from a line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to cut a specific pattern from a line
# 1  
Old 07-10-2016
Need to cut a specific pattern from a line

Hello,
I need to cut a specific pattern from a line irrespecitve of knowing field place.

I am aware to cut field if you know the place of the field, but for me The sting place varies.
Code:
1468129514436,0,something_error,Non HTTP response code: java.net.URISyntaxException,Non HTTP response message: Illegal character in query at index 81: http://xxx:000/abcd/jsp/soh/fixedinquiries/InquiryFrameSet.jsp?accountSuffix=${SUFFIX_ID}&accountNumber=Number Not Found&domainName=%20&corpUserName=%20&accountId=${ACCOUNT_ID}&pgCode=M&pCode=${PCODE}&imsiNumber=${IMSI_ID}&evisionSTBSerialNo=%20&eccNumber12=%20&arabicDomainName=%20&operation=3&searchPage=SOHACCOUNTIDINQ,Thread Group 1-1,text,false,1226,1,1,0

out of above line I am able to get
Code:
cat log.jtl | egrep 'false'| egrep  'http://' | cut -d ',' -f3

False and http will always be there , by above command I get error line and i also get 3rd filed. but i also want to print URL in the error

Code:
something_error   http://xxx:000/abcd





Moderator's Comments:
Mod Comment Please use code tags, not icode tags.

Last edited by RudiC; 07-10-2016 at 05:31 AM.. Reason: Changed ICODE tags to CODE tags.
# 2  
Old 07-10-2016
Not too clear what you really want. Based on what I infer, try
Code:
awk -F, '/false/ && match ($0, /http:\/\/[^\/]*\/[^\/]*/) {print $3, substr ($0, RSTART, RLENGTH)}' file3
something_error http://xxx:000/abcd


Last edited by RudiC; 07-10-2016 at 06:11 AM..
# 3  
Old 07-10-2016
I got below error.
I want to print the third field and the the url .
url is not at specific position every time, it can be at filed 10, 12 13 and so on.
i want script to pick where ever it is in the line
Code:
awk: syntax error near line 1
awk: bailing out near line 1

Moderator's Comments:
Mod Comment Pleae use CODE tags (not ICODE tags) when displaying full-line and multi-line sample input, sample output, and code segments.

Last edited by Don Cragun; 07-10-2016 at 05:59 AM.. Reason: Change ICODE tags to CODE tags.
# 4  
Old 07-10-2016
Quote:
Originally Posted by mirwasim
I got below error.
I want to print the third field and the the url .
url is not at specific position every time, it can be at filed 10, 12 13 and so on.
i want script to pick where ever it is in the line
Code:
awk: syntax error near line 1
awk: bailing out near line 1

Moderator's Comments:
Mod Comment Pleae use CODE tags (not ICODE tags) when displaying full-line and multi-line sample input, sample output, and code segments.
When using awk on Solaris/SunOS systems, change awk to /usr/xpg4/bin/awk or nawk.
# 5  
Old 07-10-2016
Thanks DON, it worked.

I will consider to use [CODE] instead of [ICODE]
# 6  
Old 07-10-2016
Again, you're not too eloquent with your request nor error description. Reading between your lines, I guess I recognize the problem. Let me cite
Quote:
Originally Posted by Don Cragun
If you are using a Solaris/SunOS system, use /usr/xpg4/bin/awk or nawk instead of awk.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

2. Shell Programming and Scripting

Replace the line with specific pattern

Hello All I'm trying to change one string from a file contening this patern: xxxx-xxxx 4 numbers - end 4 other numbers This is a sample of the file: LDR 00679 am a2200205 4500 =001 3617 =008 030219s2000\\\\xxx|||||\||||\00|\0\spa\d =020 \\$a0211-1942 =041 \\$aCastellà =093 ... (5 Replies)
Discussion started by: ldiaz2106
5 Replies

3. Shell Programming and Scripting

Replace string in line below specific pattern?

Hi, I'm trying to replace a string with sed, in a text file containing this pattern: location alpha value x location beta value y location gamma value y location delta value y location theta value z ... What I want to achieve is: Find location beta into text file... (1 Reply)
Discussion started by: TECK
1 Replies

4. Shell Programming and Scripting

sed or awk, cut, to extract specific data from line

Hi guys, I have been trying to do this, but... no luck so maybe you can help me. I have a line like this: Total Handled, Received, on queue Input Mgs: 140 / 14 => 0 I need to, get the number after the / until the =, to get only 14 . Any help is greatly appreciated. Thanks, (4 Replies)
Discussion started by: ocramas
4 Replies

5. Programming

Print specific pattern line in c++

Input file: @HWI-BRUNOP1_header_1 GACCAATAAGTGATGATTGAATCGCGAGTGCTCGGCAGATTGCGATAAAC +HWI-BRUNOP1_header_1 TNTTJTTTETceJSP__VRJea`_NfcefbWe Desired output file: >HWI-BRUNOP1_header_1 GACCAATAAGTGATGATTGAATCGCGAGTGCTCGGCAGATTGCGATAAAC >HWI-BRUNOP1_header_2... (10 Replies)
Discussion started by: cpp_beginner
10 Replies

6. Shell Programming and Scripting

cut specific pattern

Hi i want to cut a variable like if it is ABCDEF then i want to cut "DEF" only Please help me regarding this. (1 Reply)
Discussion started by: aishsimplesweet
1 Replies

7. Shell Programming and Scripting

How to cut specific line and one line under?

Hi guys, I need to analyze the following alert log file: Beginning log switch checkpoint up to RBA , SCN: 3916025539605 Sat May 1 00:54:52 2010 Thread 1 advanced to log sequence 271423 (LGWR switch) Current log# 1 seq# 271423 mem# 0: /dw/stg_redo01/log_dwstg_g1_m1.log Current log# 1... (7 Replies)
Discussion started by: nir_s
7 Replies

8. Shell Programming and Scripting

How to cut first line only from a text near a specific column without cutting a word

First I have to say thank you to this community and this forum. You helped me very much builing several useful scripts. Now, I can't get a solution the following problem, I'm stuck somehow. Maybe someone has an idea. In short, I dump a site via lynx and pipe the output in a file. I need to... (7 Replies)
Discussion started by: lowmaster
7 Replies

9. Shell Programming and Scripting

To cut a specific line

Hi, I need to remove a specific line from a file.. For eg: From the html codings, I need to find the word "iframe frameborder" and cut it . I tried with find . -type f -exec grep -H 'iframe frameborder' {} \; > <filename> From the output of this result, I need to remove the "iframe... (14 Replies)
Discussion started by: gsiva
14 Replies

10. Shell Programming and Scripting

merge columns into one line after a specific pattern

Hi all, im a linux newbie, plz help! I have a file - box -------- Fox-2 -------- UF29 zip42 -------- zf-CW SNF2_N Heli_Z -------- Fox -------- Kel_1 box (3 Replies)
Discussion started by: sam_2921
3 Replies
Login or Register to Ask a Question