Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk with sed to combine lines and remove specific odd # pattern from line Post 303033775 by RavinderSingh13 on Thursday 11th of April 2019 01:53:32 PM
Old 04-11-2019
Hello cmccabe,

My previous solution works with reading Input_file 2 times, try following with reading Input_file single time only.
Code:
awk '!NF || (!/^xxxx_[0-9]+/ && !/^[0-9]+/){
  print
  next
}
!/^xxxx_[0-9]+/{
  line=$0
  next
}
{
  for(i=1;i<=NF;i++){
     val=$i
     sub(/.*_/,"",val)
     if(val%2==0){
         value=(value?value OFS:"")$i
     }
  }
  print value,line
  line=val=value=""
}
END{
  if(line){
     print line
  }
}'   Input_file

Output will be as follows.
Code:
xxxx_0002 00-0000-Lname-Fname-REPEAT
xxxx_0008 111111-yyyy
xxxx_0006 111111-yyyy-0
FileName_ID

FileName_ID

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

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

Sed or Awk to remove specific lines

I have searched the forum for this - forgive me if I missed a previous post. I have the following file: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah alter table "informix".esc_acct add constraint (foreign key (fi_id) references "informix".fi ... (5 Replies)
Discussion started by: Shoeless_Mike
5 Replies

3. Shell Programming and Scripting

NAWK to remove lines that matches a specific pattern

Hi, I have requirement that I need to split my input file into two files based on a search pattern "abc" For eg. my input file has below content abc defgh zyx I need file 1 with abc and file2 with defgh zyx I can use grep command to acheive this. But with grep I need... (8 Replies)
Discussion started by: sbhuvana20
8 Replies

4. Shell Programming and Scripting

Awk-sed help : to remove first and last line with pattern match:

awk , sed Experts, I want to remove first and last line after pattern match "vg" : I am trying : # sed '1d;$d' works fine , but where the last line is not having vg entry it is deleting one line of data. - So it should check for the pattern vg if present , then it should delete the line ,... (5 Replies)
Discussion started by: rveri
5 Replies

5. Shell Programming and Scripting

Replacing lines matching a multi-line pattern (sed/perl/awk)

Dear Unix Forums, I am hoping you can help me with a pattern matching problem. What am I trying to do? I want to replace multiple lines of a text file (that match a multi-line pattern) with a single line of text. These patterns can span several lines and do not always have the same number of... (10 Replies)
Discussion started by: thefang
10 Replies

6. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 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. Shell Programming and Scripting

awk to combine all matching fields in input but only print line with largest value in specific field

In the below I am trying to use awk to match all the $13 values in input, which is tab-delimited, that are in $1 of gene which is just a single column of text. However only the line with the greatest $9 value in input needs to be printed. So in the example below all the MECP2 and LTBP1... (0 Replies)
Discussion started by: cmccabe
0 Replies

9. 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

10. Shell Programming and Scripting

sed to remove next 15 lines after pattern in Solaris

Team, I am trying to use sed to delete 15 lines, after pattern patch, which includes the pattern as well in Solaris. I used the below command, as we do it Linux, but it's not working as expected in Solaris. I am getting the error as "garbled".sed '/\/table/,+15d' status.html sed: command... (8 Replies)
Discussion started by: Nagaraj R
8 Replies
ODE(1)                                                        GNU Plotting Utilities                                                        ODE(1)

NAME
ode - numerical solution of ordinary differential equations SYNOPSIS
ode [ options ] [ file ] DESCRIPTION
ode is a tool that solves, by numerical integration, the initial value problem for a specified system of first-order ordinary differential equations. Three distinct numerical integration schemes are available: Runge-Kutta-Fehlberg (the default), Adams-Moulton, and Euler. The Adams-Moulton and Runge-Kutta schemes are available with adaptive step size. The operation of ode is specified by a program, written in its input language. The program is simply a list of expressions for the deriva- tives of the variables to be integrated, together with some control statements. Some examples are given in the EXAMPLES section. ode reads the program from the specified file, or from standard input if no file name is given. If reading from standard input, ode will stop reading and exit when it sees a single period on a line by itself. At each time step, the values of variables specified in the program are written to standard output. So a table of values will be produced, with each column showing the evolution of a variable. If there are only two columns, the output can be piped to graph(1) or a similar plotting program. OPTIONS
Input Options -f file --input-file file Read input from file before reading from standard input. This option makes it possible to work interactively, after reading a pro- gram fragment that defines the system of differential equations. Output Options -p prec --precision prec When printing numerical results, use prec significant digits (the default is 6). If this option is given, the print format will be scientific notation. -t --title Print a title line at the head of the output, naming the variables in each column. If this option is given, the print format will be scientific notation. Integration Scheme Options The following options specify the numerical integration scheme. Only one of the three basic options -R, -A, -E may be specified. The default is -R (Runge-Kutta-Fehlberg). -R [stepsize] --runge-kutta [stepsize] Use a fifth-order Runge-Kutta-Fehlberg algorithm, with an adaptive stepsize unless a constant stepsize is specified. When a con- stant stepsize is specified and no error analysis is requested, then a classical fourth-order Runge-Kutta scheme is used. -A [stepsize] --adams-moulton [stepsize] Use a fourth-order Adams-Moulton predictor-corrector scheme, with an adaptive stepsize unless a constant stepsize, stepsize, is specified. The Runge-Kutta-Fehlberg algorithm is used to get past `bad' points (if any). -E [stepsize] --euler [stepsize] Use a `quick and dirty' Euler scheme, with a constant stepsize. The default value of stepsize is 0.1. Not recommended for serious applications. The error bound options -r and -e (see below) may not be used if -E is specified. -h hmin [hmax] --step-size-bound hmin [hmax] Use a lower bound hmin on the stepsize. The numerical scheme will not let the stepsize go below hmin. The default is to allow the stepsize to shrink to the machine limit, i.e., the minimum nonzero double-precision floating point number. The optional argument hmax, if included, specifies a maximum value for the stepsize. It is useful in preventing the numerical rou- tine from skipping quickly over an interesting region. Error Bound Options -r rmax [rmin] --relative-error-bound rmax [rmin] The -r option sets an upper bound on the relative single-step error. If the -r option is used, the relative single-step error in any dependent variable will never exceed rmax (the default for which is 10^-9). If this should occur, the solution will be aban- doned and an error message will be printed. If the stepsize is not constant, the stepsize will be decreased `adaptively', so that the upper bound on the single-step error is not violated. Thus, choosing a smaller upper bound on the single-step error will cause smaller stepsizes to be chosen. A lower bound rmin may optionally be specified, to suggest when the stepsize should be increased (the default for rmin is rmax/1000). -e emax [emin] --absolute-error-bound emax [emin] Similar to -r, but bounds the absolute rather than the relative single-step error. -s --suppress-error-bound Suppress the ceiling on single-step error, allowing ode to continue even if this ceiling is exceeded. This may result in large numerical errors. Informational Options --help Print a list of command-line options, and exit. --version Print the version number of ode and the plotting utilities package, and exit. DIAGNOSTICS
Mostly self-explanatory. The biggest exception is `syntax error', meaning there is a grammatical error. Language error messages are of the form ode: nnn: message... where `nnn' is the number of the input line containing the error. If the -f option is used, the phrase "(file)" follows the `nnn' for errors encountered inside the file. Subsequently, when ode begins reading the standard input, line numbers start over from 1. No effort is made to recover successfully from syntactic errors in the input. However, there is a meager effort to resynchronize so more than one error can be found in one scan. Run-time errors elicit a message describing the problem, and the solution is abandoned. EXAMPLES
The program y' = y y = 1 print t, y step 0, 1 solves an initial value problem whose solution is y=e^t. When ode runs this program, it will write two columns of numbers to standard out- put. Each line will show the value of the independent variable t, and the variable y, as t is stepped from 0 to 1. A more sophisticated example would be sine' = cosine cosine' = -sine sine = 0 cosine = 1 print t, sine step 0, 2*PI This program solves an initial value problem for a system of two differential equations. The initial value problem turns out to define the sine and cosine functions. The program steps the system over a full period. AUTHORS
ode was written by Nicholas B. Tufillaro (nbt@reed.edu), and slightly enhanced by Robert S. Maier (rsm@math.arizona.edu) to merge it into the GNU plotting utilities. SEE ALSO
"The GNU Plotting Utilities Manual". BUGS
Email bug reports to bug-gnu-utils@gnu.org. FSF Dec 1998 ODE(1)
All times are GMT -4. The time now is 01:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy