Sponsored Content
Top Forums Shell Programming and Scripting How to use SED to join multiple lines? Post 302381704 by DrivesMeCrazy on Saturday 19th of December 2009 11:53:50 PM
Old 12-20-2009
How to use SED to join multiple lines?

Hi guys,

anyone know how can i join multiples lines using sed till the end of a file and output to another file in a single line?
The end of each line will be replaced with a special char "#".

I am using the below SED command, however it seems to remove the last 2 lines. Also not all lines are joined together.
Code:
sed 'N;N;s/\n/#/g'

Example of Input File:
Code:
Builtin :Sign CA
"CN=CA,OU=Root CA,O=Sign nv-sa,C=BE"
"CN=CA,OU=Root CA,O=Sign nv-sa,C=BE"
04:00:00:00:5A:C3:94
3E:09:51:92:E1:B7:5D:37:9F:B1:87:29:8A
rsa
2048
Sep 1, 1990 8:00:00 PM
Jan 30, 2020 8:00:00 PM
false
true
true
false
true
true
false
false


TIA
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk Join multiple lines

Hi, I have data with broken lines: Sample data: "12"|"25"|"a"|"b"|"c"|"d"|"e"|"f"|"2453748"|"08:10:50" "16"|"25"|"a"|"b"|"c"|"d"|"e"|"f"|" 2453748"|"08:15:50" "16"|"25"|"a"|"b"|" c"|"d"|"e"|"f"|"2453748"|"08:19:50" "16"|"25"|"a"|"b"|"c"|"d"|"e"|"f"|"2453748"|"08:19:50" In the... (5 Replies)
Discussion started by: hitmansilentass
5 Replies

2. Shell Programming and Scripting

join on a file with multiple lines, fields

I've looked at the join command which is able to perform what I need on two rows with a common field, however if I have more than two rows I need to join all of them. Thus I have one file with multiple rows to be joined on an index number: 1 randomtext1 2 rtext2 2 rtext3 3 rtext4 3 rtext5... (5 Replies)
Discussion started by: crimper
5 Replies

3. UNIX for Dummies Questions & Answers

Join 2 files with multiple columns: awk/grep/join?

Hello, My apologies if this has been posted elsewhere, I have had a look at several threads but I am still confused how to use these functions. I have two files, each with 5 columns: File A: (tab-delimited) PDB CHAIN Start End Fragment 1avq A 171 176 awyfan 1avq A 172 177 wyfany 1c7k A 2 7... (3 Replies)
Discussion started by: InfoSeeker
3 Replies

4. UNIX for Dummies Questions & Answers

sed, join lines that do not match pattern

Hello, Could someone help me with sed. I have searched for solution 5 days allready :wall:, but cant find. Unfortunately my "sed" knowledge not good enough to manage it. I have the text: 123, foo1, bar1, short text1, dat1e, stable_pattern 124, foo2, bar2, long text with few lines, date,... (4 Replies)
Discussion started by: petrasl
4 Replies

5. Shell Programming and Scripting

Join multiple lines

Hi I have a source file ( written i C ) where a funtion call is spread over multiple lines, for example : func( a, b, c ); I want this to be joined into one single line : func(a,b,c); How can this be done with awk and sed ? Regards. Hench (2 Replies)
Discussion started by: hench
2 Replies

6. Shell Programming and Scripting

Join common patterns in multiple lines into one line

Hi I have a file like 1 2 1 2 3 1 5 6 11 12 10 2 7 5 17 12 I would like to have an output as 1 2 3 5 6 10 7 11 12 17 any help would be highly appreciated Thanks (4 Replies)
Discussion started by: Harrisham
4 Replies

7. Shell Programming and Scripting

Join multiple lines from text file

Hi Guys, Could you please advise how to join multiple details lines into single row, with HEADER 1 as the record separator and comma(,) as the field separator. Input: HEADER 1, HEADER 2, HEADER 3, 11,22,33, COLUMN1,COLUMN2,COLUMN3, AA1, BB1, CC1, END: ABC HEADER 1, HEADER 2,... (3 Replies)
Discussion started by: budz26
3 Replies

8. Shell Programming and Scripting

Join lines using sed or awk

Hi, I have text file that looks like this: blabla bla PATTERN LINE1 LINE2 bla bla bla PATTERN LINE1 LINE2 bla PATTERN LINE1 LINE2 bla (9 Replies)
Discussion started by: hench
9 Replies

9. UNIX for Beginners Questions & Answers

Sed/awk join lines once pattern found

Hi all OS - RHEL6.4 I have input file -f1.txt I need to search line which starts with \Start and read next line till it gets blank line and join them all. I need to trim any trailing spaces for each line.So output.txt should be.. \Start\now\fine stepwatch this space for toolsends... (7 Replies)
Discussion started by: krsnadasa
7 Replies

10. Shell Programming and Scripting

Join columns across multiple lines in a Text based on common column using BASH

Hello, I have a file with 2 columns ( tableName , ColumnName) delimited by a Pipe like below . File is sorted by ColumnName. Table1|Column1 Table2|Column1 Table5|Column1 Table3|Column2 Table2|Column2 Table4|Column3 Table2|Column3 Table2|Column4 Table5|Column4 Table2|Column5 From... (6 Replies)
Discussion started by: nv186000
6 Replies
FAM.CONF(5)								SGI							       FAM.CONF(5)

NAME
fam.conf - The File Alteration Monitor (FAM) configuration file SYNOPSIS
In addition to its command line options, famd's behavior can also be controlled through its configuration file. By default, this is /etc/fam.conf. The -c command line option can be used to specify an alternate file. FILE FORMAT
Configuration lines are in the format option=value. Lines beginning with # or ! are ignored. famd recognizes the following options: insecure_compatibility If set to true, this disables authentication and reduces access security as described under SECURITY below. This is false by default. Setting this option to true is the same as using the -C command line option. untrusted_user This is the user name or UID of the user account which famd will use for unauthenticated clients. If a file can't be stated by this user, famd will not tell unauthenticated clients about the file's existence. If an untrusted user is not given in the configuration file, famd will write an error message to the system log and terminate. local_only If set to true, famd will ignore requests from remote famds. This is false by default. Setting this option to true is the same as using the -L command line option. This option is ignored if famd is started by inetd. idle_timeout This is the time in seconds that famd will wait before exiting after its last client disconnects. The default is 5 seconds. This option is overridden by the -T command line option. nfs_polling_interval This is the interval in seconds between polling files over an NFS filesystem. The default is 6 seconds. This option is overridden by the -t command line option. xtab_verification If set to true, famd will check the list of exported filesystems when remote requests are received to verify that the requests fall on filesystems which are exported to the requesting hosts. This is true by default. If this option is set to false, famd will service remote requests without attempting to perform the verification. If the local_only configuration option or -L command line option is used, xtab_verification has no effect. detect_readonly_filesystems If set to true, famd will try to detect read-only filesystems. Such filesystems are assumed to never change. This is false by default. Setting this option to true is the same as using the -r command line option. SEE ALSO
fam.conf (fam 2.6.10) January 19, 2003 FAM.CONF(5)
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy