Sponsored Content
Full Discussion: Concatenating lines in bash
Top Forums Shell Programming and Scripting Concatenating lines in bash Post 302419140 by Supersymmetric on Thursday 6th of May 2010 11:19:56 AM
Old 05-06-2010
Concatenating lines in bash

Hi,

I'm attempting to join two lines in a file which are separated by a line break. The file contents are shown below:
Code:
event_id=0
id=0_20100505210853
IFOconfig=HLV
template=TaylorF2
Nlive=1000.0
Nruns=1.0
NIFO=3
injectionXML_path=/home/rorysmith/Projects/SpinStudy/HL-INJECTIONS_1-933374636-10000.xml
param_names=['logM', 'eta', 'time', 'phi', 'distMpc', 'long', 'lat', 'psi', 'iota']
results_dir=/home/rorysmith/WWW/SpinStudy
events_page=0/HLV
data_path=/home/rorysmith/Projects/SpinStudy/0/HLV
data_files="output.0.dat"
Nruns_actual=1
timestamp_runs=
timestamp_results=20100505210853
inspnest_cmd=
gitID_runs=
gitID_results=
NOISE_WINDOW=
Deta=
Mmin=
Mmax=
DT=0.2
sub_IFOconfig=['LV', 'H', 'HL', 'V', 'L', 'HV']
other_IFOconfig=['LV', 'H', 'HL', 'V', 'HLV', 'L', 'HV']
injF_file_list=[]
injT_file_list=[]
templateF_file_list=[]
injSNR=[('H1', 3.667618989944458) ('L1', 5.1920042037963867)
 ('V1', 1.9253799915313721)]
H_TYPE=LALLIGO
L_TYPE=LALLIGO
V_TYPE=LALVirgo
H_CHANNEL=LALLIGO
L_CHANNEL=LALLIGO
V_CHANNEL=LALVirgo
N_SEGS=400
SAMPLING_RATE=1024
NMCMC=100
INJ_NO=0

where the two lines to be joined are

Code:
injSNR=[('H1', 3.667618989944458) ('L1', 5.1920042037963867)
 ('V1', 1.9253799915313721)]

I've been following similar problems which people have resolved using sed or awk, however they seem to mainly focus on removing all line breaks.

What I'm ideally looking for is a way to specify which line break to remove, perhaps by line number if this is possible?...

Last edited by Franklin52; 05-06-2010 at 12:23 PM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Concatenating lines and formatting.

Hi, I have a html file which is unformatted and need to concatenate the lines between each "table" statement in order to run an awk statement on it. Here is the example of the raw file: <table border="0" cellspacing="0" cellpadding="0" class="playerDetails"> def ... (3 Replies)
Discussion started by: Tonka52
3 Replies

2. Shell Programming and Scripting

Concatenating the two lines in a file

hi My requirement is i have a file with some records like this file name ::xyz a=1 b=100,200 ,300,400 ,500,600 c=700,800 d=900 i want to change my file a=1 b=100,200,300,400 c=700,800 d=900 if record starts with " , " that line should fallows the previous line.please give... (6 Replies)
Discussion started by: srivsn
6 Replies

3. Shell Programming and Scripting

Concatenating the lines with different pattern

Hi, I have put a similar question in one of the other threads through which I got the solution shown below but I have some more condition to add to it, hence have further queries on it. I appologies if I should be putting this with the old thread. I have a file which perform a grep on the... (1 Reply)
Discussion started by: simi28
1 Replies

4. Shell Programming and Scripting

awk: switching lines and concatenating lines?

Hello, I have only recently begun with awk and need to write this: I have an input consisting of a couple of letters, a space and a number followed by various other characters: fiRcQ 9( ) klsRo 9( ) pause fiRcQ 9( ) pause klsRo continue 1 aPLnJ 62( ) fiRcQ continue 5 ... and so on I... (7 Replies)
Discussion started by: Borghal
7 Replies

5. Shell Programming and Scripting

Concatenating lines ending with '+' using awk

Hi, I have an ASCII text file where some of the lines are ending with '+' character. I have to concatenate the next successive line with those lines having the trailing '+' char by removing that char. The below awk code has some problems to do this task: awk '{while(sub(/\+$/,"")) {... (12 Replies)
Discussion started by: royalibrahim
12 Replies

6. Shell Programming and Scripting

bash -- concatenating values from variables

Hi This is a simple one but I got a lost in translation when doing. What I want to do, given both variables in the example below, to get one value at the time from both variables, for example: 1:a 2:b etc... I need to get this in bash scripting code: varas="1 2 3 4" varbs="a b c d"... (4 Replies)
Discussion started by: ranmanh
4 Replies

7. Shell Programming and Scripting

Concatenating more than two lines into one based on some columns

Hi, I need to concatenate some lines in a file based on the First 4 coloumns of a file .. (For Eg.) Consider a file ... I,01,000002,0666,00000.00,000,00,000,000, ,0 I,01,000002,0667,00000.00,000,00,000,000, ,0 I,01,000002,0666,00056.10 I,01,000002,0667,00056.10 I,01,000002,0666,00001... (6 Replies)
Discussion started by: Sri3001
6 Replies

8. Shell Programming and Scripting

Concatenating the lines of a data

I have a data of 1 lac lines with the following format abcde,1,2,3,4, ,ee ,ff ,gg ,hh ,mm abcde,3,4,5,6, ,we ,qw ,as ,zx ,cf abcde,1,5,6,7, ,dd ,aa ,er .... .... (6 Replies)
Discussion started by: aravindj80
6 Replies

9. Shell Programming and Scripting

Concatenating strings and run it in bash

Hi, all, I tried to write a simple shell script as follow: #!/bin/bash # What want to do in bash is following # : pcd_viewer cloud_cluster_0.pcd cloud_cluster_1.pcd cloud_cluster_2.pcd cloud_cluster_3.pcd cloud_cluster_4.pcd STR = "pcd_viewer" for i in `seq 0 4` do STR... (1 Reply)
Discussion started by: bedeK
1 Replies

10. UNIX for Beginners Questions & Answers

Concatenating two mutiline variables in a bash

Hi All, I am having a situation where am capturing results in two variables from an xml file. However, I am looking to print those two variables with pipe in between them and these variable are multi-line. This is how my 1st variable looks like: 20181225010 20190224010 20190224010... (8 Replies)
Discussion started by: svks1985
8 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a file name containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy