Sponsored Content
Top Forums Shell Programming and Scripting awk to combine lines if fields match in lines Post 302997496 by cmccabe on Monday 15th of May 2017 08:30:51 AM
Old 05-15-2017
Thank you as always for the great help and explanations Smilie.

---------- Post updated at 07:30 AM ---------- Previous update was at 07:00 AM ----------

I am still a bit confused on this concept:

Quote:
#### Putting the values of subtring whose value starts from RSTART+1 to RLENGTH-2, here point to be noted RSTART and RLENGTH are the OOTB awk's keywords which will be SET when a match is found, we have done this match for 5th field above
I guess my confusion is what defines RSTART+1 and RLENGTH-2 in this line but RSTART+20 and RLENGH-22 in the print?

In the first RSTART $5 was used as the substring, so chr15:88483984, so is RSTART+1 the chr15 and RLENGTH-2 = to :88483984? Thank you Smilie.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

SImple HELP! how to combine two lines together using sed or awk..

hi..im new to UNIX... ok i have this information in the normal shell... there are 2 lines display like this: h@hotmail.com k@hotmail.com i want it to display like this with a space betweem them h@hotmail.com k@hotmail.com the information is stored in a text file.... anyone... (10 Replies)
Discussion started by: forevercalz
10 Replies

2. Shell Programming and Scripting

search and combine lines in awk

Hi All, I have 1 "keyword" file like this: 00-1F-FB-00-04-18 00-19-CB-8E-66-DF 00-1F-FB-00-48-9C 00-1F-FB-00-AA-4F .... and the 2nd "details" file like this: Wed Feb 11 00:00:02 2009 NAS-IP-Address = xxxxxxxxxxxxxxxxxx Class = "P1-SHT-AAA01;1233704662;4886720" ... (6 Replies)
Discussion started by: xajax7
6 Replies

3. UNIX for Dummies Questions & Answers

awk display the match and 2 lines after the match is found.

Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file. For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt I tried with grep -A but it's not supported on my system. I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies

4. Shell Programming and Scripting

Print only lines where fields concatenated match strings

Hello everyone, Maybe somebody could help me with an awk script. I have this input (field separator is comma ","): 547894982,M|N|J,U|Q|P,98,101,0,1,1 234900027,M|N|J,U|Q|P,98,101,0,1,1 234900023,M|N|J,U|Q|P,98,54,3,1,1 234900028,M|H|J,S|Q|P,98,101,0,1,1 234900030,M|N|J,U|F|P,98,101,0,1,1... (2 Replies)
Discussion started by: Ophiuchus
2 Replies

5. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

6. Shell Programming and Scripting

Awk: Combine multiple lines based on number of fields

If a file has following kind of data, comma delimited 1,2,3,4 1 1 1,2,3,4 1,2 2 2,3,4 My required output must have only 4 columns with comma delimited 1,2,3,4 111,2,3,4 1,222,3,4 I have tried many awk command using ORS="" but couldnt progress (10 Replies)
Discussion started by: mdkm
10 Replies

7. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies

8. UNIX for Beginners Questions & Answers

How to count lines of CSV file where 2 fields match variables?

I'm trying to use awk to count the occurrences of two matching fields of a CSV file. For instance, for data that looks like this... Joe,Blue,Yes,No,High Mike,Blue,Yes,Yes,Low Joe,Red,No,No,Low Joe,Red,Yes,Yes,Low I've been trying to use code like this... countvar=`awk ' $2~/$color/... (4 Replies)
Discussion started by: nmoore2843
4 Replies

9. Shell Programming and Scripting

awk to combine matching lines in file

I am trying to combine all matching lines in the tab-delimited using awk. The below runs but no output results. Thank you :). input chrX 110925349 110925532 ALG13 chrX 110925349 110925532 ALG13 chrX 110925349 110925532 ALG13 chrX 47433390 47433999 SYN1... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Shell Programming and Scripting

awk to remove lines that do not start with digit and combine line or lines

I have been searching and trying to come up with an awk that will perform the following on a converted text file (original is a pdf). 1. Since the first two lines are (begin with) text they are removed 2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Discussion started by: cmccabe
3 Replies
RSTART(1)						      General Commands Manual							 RSTART(1)

NAME
rstart - a sample implementation of a Remote Start client SYNOPSIS
rstart [-c context] [-g] [-l username] [-v] hostname command args ... DESCRIPTION
Rstart is a simple implementation of a Remote Start client as defined in "A Flexible Remote Execution Protocol Based on rsh". It uses rsh as its underlying remote execution mechanism. OPTIONS
-c context This option specifies the context in which the command is to be run. A context specifies a general environment the program is to be run in. The details of this environment are host-specific; the intent is that the client need not know how the environment must be configured. If omitted, the context defaults to X. This should be suitable for running X programs from the host's "usual" X installation. -g Interprets command as a generic command, as discussed in the protocol document. This is intended to allow common applications to be invoked without knowing what they are called on the remote system. Currently, the only generic commands defined are Terminal, LoadMonitor, ListContexts, and ListGenericCommands. -l username This option is passed to the underlying rsh; it requests that the command be run as the specified user. -v This option requests that rstart be verbose in its operation. Without this option, rstart discards output from the remote's rstart helper, and directs the rstart helper to detach the program from the rsh connection used to start it. With this option, responses from the helper are displayed and the resulting program is not detached from the connection. NOTES
This is a trivial implementation. Far more sophisticated implementations are possible and should be developed. Error handling is nonexistent. Without -v, error reports from the remote are discarded silently. With -v, error reports are displayed. The $DISPLAY environment variable is passed. If it starts with a colon, the local hostname is prepended. The local domain name should be appended to unqualified host names, but isn't. The $SESSION_MANAGER environment variable should be passed, but isn't. X11 authority information is passed for the current display. ICE authority information should be passed, but isn't. It isn't completely clear how rstart should select what ICE authority information to pass. Even without -v, the sample rstart helper will leave a shell waiting for the program to complete. This causes no real harm and consumes relatively few resources, but if it is undesirable it can be avoided by explicitly specifying the "exec" command to the shell, eg rstart somehost exec xterm This is obviously dependent on the command interpreter being used on the remote system; the example given will work for the Bourne and C shells. SEE ALSO
rstartd(1), rsh(1), A Flexible Remote Execution Protocol Based on rsh AUTHOR
Jordan Brown, Quarterdeck Office Systems X Version 11 rstart 1.0.4 RSTART(1)
All times are GMT -4. The time now is 09:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy