Sponsored Content
Top Forums Shell Programming and Scripting Append each line to next previous line in a file Post 302321444 by sudhakaryadav on Monday 1st of June 2009 07:38:16 AM
Old 06-01-2009
Append each line to next previous line in a file

Hi all,
Please help me in providing sample code to append the following 4 lines in one row.

Input :

A1/EXT "BAPBSC10/07B/00" 523 090530 0115
RXOCF-430 HY1711 1
EXTERNAL ALARM
DOOR ALARM

Output should be :
A1/EXT "BAPBSC10/07B/00" 523 090530 0115 RXOCF-430 HY1711 DOOR ALARM
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append line that does not contain pipe to it previous line

Hi All, I have a file which contains data as below When we see no pipe character in the line. append those lines to the previous line with pipe character till we get the next line with pipe character with ~(concat with ~) Input file looks like: 1080530944|001|john.l.bonner|Acknowledge|CN... (11 Replies)
Discussion started by: ainuddin
11 Replies

2. UNIX for Advanced & Expert Users

append the line with the previous if it not start with 1=

How to append the line with the previous if it not start with 1=. 1=ttt, 2=xxxxxx, 3=4545 44545, 4=66666, 1=ttt, 2=xxxxxx, 3=34434 3545, 4=66666, 5=ffffff 6=uuuuuuu, 7=ooooooo 1=ttt, 2=xxxxxx, 3=311343545, 4=66666 1=ttt, 2=xxxxxx, 5=XAXAXA, 7=FDFD (3 Replies)
Discussion started by: palsevlohit_123
3 Replies

3. Shell Programming and Scripting

SED or AWK "append line to the previous line"

Hi, How can I remove the line beak in the following case if the line begin with the special char “;”? TEXT Text;text ;text Text;text;text I want to convert the text to: Text;text;text Text;text;text I have already tried to use... (31 Replies)
Discussion started by: research3
31 Replies

4. Shell Programming and Scripting

Append specific lines to a previous line based on sequential search criteria

I'll try explain this as best I can. Let me know if it is not clear. I have large text files that contain data as such: 143593502 09-08-20 09:02:13 xxxxxxxxxxx xxxxxxxxxxx 09-08-20 09:02:11 N line 1 test line 2 test line 3 test 143593503 09-08-20 09:02:13... (3 Replies)
Discussion started by: jesse
3 Replies

5. Shell Programming and Scripting

Append next line to previous line when one pattern not found

Hi, I need help for below scenario.I have a flat file which is having records seperated by delimiters which will represent each record for oracle table.My Control file will consider each line as one record for that table. Some of the lines are aligned in two/three lines so that records are... (4 Replies)
Discussion started by: kannansr621
4 Replies

6. Shell Programming and Scripting

Append next line to previous lines when NF is less than 0

Hi All, This is very urgent, I've a data file with 1.7 millions rows in the file and the delimiter is cedilla and I need to format the data in such a way that if the NF in the next row is less than 1, it will append that value to previous line. Any help will be appricated. Thanks,... (17 Replies)
Discussion started by: cumeh1624
17 Replies

7. UNIX for Dummies Questions & Answers

How to remove fields space and append next line to previous line.?

awk 'BEGIN{FS = "Ç"} NR == 1 {p = $0; next} NF > 1 {print p; p = $0} NF <= 1 {p = (p " " $0)} END {print p}' input.txt > output.txt This is what the input data file looks like with broken lines Code: 29863 Ç890000000 Ç543209911 ÇCHNGOHG Ç000000001 Ç055 ... (4 Replies)
Discussion started by: cumeh1624
4 Replies

8. UNIX for Advanced & Expert Users

How to find a string in a line in UNIX file and delete that line and previous 3 lines ?

Hi , i have a file with data as below.This is same file. But actual file contains to many rows. i want to search for a string "Field 039 00" and delete that line and previous 3 lines in that file.. Can some body suggested me how can i do using either sed or awk command ? Field 004... (7 Replies)
Discussion started by: vadlamudy
7 Replies

9. Shell Programming and Scripting

Issue while append to previous line

Hi, I have data as below. 36578019,005-923887317,UNMDL,20151230,2C3CCAAG4GH135448,L,TX,20160108,62,"030916 PPT TX AFF RPRT VALID AFF IN PDP WLL FWD TO RYAN ON 031116 CB1619 ",, 36580219,611-923785453,FC,20151209,ZACCJABT9FPC19274,L,TX,20160108,83,,,... (4 Replies)
Discussion started by: JSKOBS
4 Replies

10. Shell Programming and Scripting

Remove new line starting with a numeric value and append it to the previous line

Hi, i have a file with multiple entries. After some tests with sed i managed to get the file output as follows: lsn=X-LINK-IN0,apc=661:0,state=avail,avail/links=1/1, 00,2110597,2094790,0,81,529,75649011,56435363, lsn=TM1ITP1-AM1ITP1-LS,apc=500:0,state=avail,avail/links=1/1,... (5 Replies)
Discussion started by: nms
5 Replies
Filename(3)							   OCaml library						       Filename(3)

NAME
Filename - Operations on file names. Module Module Filename Documentation Module Filename : sig end Operations on file names. val current_dir_name : string The conventional name for the current directory (e.g. . in Unix). val parent_dir_name : string The conventional name for the parent of the current directory (e.g. .. in Unix). val dir_sep : string The directory separator (e.g. / in Unix). Since 3.11.2 val concat : string -> string -> string concat dir file returns a file name that designates file file in directory dir . val is_relative : string -> bool Return true if the file name is relative to the current directory, false if it is absolute (i.e. in Unix, starts with / ). val is_implicit : string -> bool Return true if the file name is relative and does not start with an explicit reference to the current directory ( ./ or ../ in Unix), false if it starts with an explicit reference to the root directory or the current directory. val check_suffix : string -> string -> bool check_suffix name suff returns true if the filename name ends with the suffix suff . val chop_suffix : string -> string -> string chop_suffix name suff removes the suffix suff from the filename name . The behavior is undefined if name does not end with the suffix suff . val chop_extension : string -> string Return the given file name without its extension. The extension is the shortest suffix starting with a period and not including a directory separator, .xyz for instance. Raise Invalid_argument if the given name does not contain an extension. val basename : string -> string Split a file name into directory name / base file name. If name is a valid file name, then concat (dirname name) (basename name) returns a file name which is equivalent to name . Moreover, after setting the current directory to dirname name (with Sys.chdir ), references to basename name (which is a relative file name) designate the same file as name before the call to Sys.chdir . This function conforms to the specification of POSIX.1-2008 for the basename utility. val dirname : string -> string See Filename.basename . This function conforms to the specification of POSIX.1-2008 for the dirname utility. val temp_file : ?temp_dir:string -> string -> string -> string temp_file prefix suffix returns the name of a fresh temporary file in the temporary directory. The base name of the temporary file is formed by concatenating prefix , then a suitably chosen integer number, then suffix . The optional argument temp_dir indicates the tempo- rary directory to use, defaulting to the current result of Filename.get_temp_dir_name . The temporary file is created empty, with permis- sions 0o600 (readable and writable only by the file owner). The file is guaranteed to be different from any other file that existed when temp_file was called. Raise Sys_error if the file could not be created. Before3.11.2 no ?temp_dir optional argument val open_temp_file : ?mode:Pervasives.open_flag list -> ?temp_dir:string -> string -> string -> string * Pervasives.out_channel Same as Filename.temp_file , but returns both the name of a fresh temporary file, and an output channel opened (atomically) on this file. This function is more secure than temp_file : there is no risk that the temporary file will be modified (e.g. replaced by a symbolic link) before the program opens it. The optional argument mode is a list of additional flags to control the opening of the file. It can contain one or several of Open_append , Open_binary , and Open_text . The default is [Open_text] (open in text mode). Raise Sys_error if the file could not be opened. Before3.11.2 no ?temp_dir optional argument val get_temp_dir_name : unit -> string The name of the temporary directory: Under Unix, the value of the TMPDIR environment variable, or "/tmp" if the variable is not set. Under Windows, the value of the TEMP environment variable, or "." if the variable is not set. The temporary directory can be changed with File- name.set_temp_dir_name . Since 4.00.0 val set_temp_dir_name : string -> unit Change the temporary directory returned by Filename.get_temp_dir_name and used by Filename.temp_file and Filename.open_temp_file . Since 4.00.0 val temp_dir_name : string Deprecated. The name of the initial temporary directory: Under Unix, the value of the TMPDIR environment variable, or "/tmp" if the vari- able is not set. Under Windows, the value of the TEMP environment variable, or "." if the variable is not set. This function is depre- cated; Filename.get_temp_dir_name should be used instead. Since 3.09.1 val quote : string -> string Return a quoted version of a file name, suitable for use as one argument in a command line, escaping all meta-characters. Warning: under Windows, the output is only suitable for use with programs that follow the standard Windows quoting conventions. OCamldoc 2014-06-09 Filename(3)
All times are GMT -4. The time now is 11:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy