Joining 3 line weirdness


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Joining 3 line weirdness
# 1  
Old 05-02-2017
Joining 3 line weirdness

Hi all you Unix/Linux gurus,

So, I have something strage going on and need a sanity check...

I have 2 files that both contain 3 lines of text...

File1 - called t:
Code:
CN66270E90
94:57:a5:d3:db:aa
94:57:a5:d3:db:ab

File2 - called tt:
Code:
hostname
5.7.2.7
72:8C:36:3B:5A:17

I want to join the three lines into one... I have a solution to this that works great on file 2 (tt) but not file1 (t) and wanted to know why...

If I run:
Code:
cat t |sed 'N;N;s/\n/,/g'

I get:
Code:
,94:57:a5:d3:db:ab

But, if I run that on tt:
Code:
cat tt | sed 'N;N;s/\n/,/g'

Works like a charm:
Code:
hostname,5.7.2.7,72:8C:36:3B:5A:17

There is nothing different about the two files, well, other than the data, but there are 3 alphanumeric lines so the sed command SHOULD work on both files, correct?

Thanks!
Joe

---------- Post updated at 01:32 PM ---------- Previous update was at 01:21 PM ----------

So, there was something different about the two files... The code is automatically generated from another process and there was a crlf at the end of the lines... So, I had to so a
Code:
sed 's/\r//g'

in the stream...

Solved :-D.

Thanks!
# 2  
Old 05-02-2017
Code:
dos2ux < infile | sed 'N;N;s/\n/,/g'

This User Gave Thanks to rdrtx1 For This Post:
# 3  
Old 05-02-2017
Quote:
Originally Posted by rdrtx1
Code:
dos2ux < infile | sed 'N;N;s/\n/,/g'

Yeah, that would work too!

Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Zpool device weirdness

Weird duplicate device in one of my nested raidz1s - device is shown as both online and unavailable, with a hot spare showing up as degraded as well. Any thoughts on how I should proceed? root@storage# zpool status tank pool: tank state: DEGRADED status: One or more devices are... (6 Replies)
Discussion started by: DoohanMcGirk
6 Replies

2. Shell Programming and Scripting

joining multi-line file into single lines

Hi, I have a file like mentioned below..For each specific id starting with > I want to join the sequence in multiple lines to a single line..Is there a simple way in awk or sed to do this >ENST00000558922 cdna:KNOWN TCCAGGATCCAGCCTCCCGATCACCGCGCTAGTCCTCGCCCTGCCTGGGCTTCCCCAGAG... (2 Replies)
Discussion started by: Diya123
2 Replies

3. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

4. Shell Programming and Scripting

Help required on joining one line above & below to the pattern matched string line.

Hi Experts, Help needed on joining one line above & below to the pattern matched string line. The input file, required output is mentioned below Input file ABCD DEFG5 42.0.1-63.38.31 KKKK iokl IP Connection Available ABCD DEFG5 42.0.1-63.38.31 ... (7 Replies)
Discussion started by: krao
7 Replies

5. Shell Programming and Scripting

File path weirdness

I want to be able to drag and drop a file into a script in the terminal but it doesn't like the /home/user prefix. How do I get around this? (8 Replies)
Discussion started by: pluto7777
8 Replies

6. Shell Programming and Scripting

Joining contents in multiple lines to a single line

I do have a file with contents splited into multiple lines ADSLHLJASHGLJSKAGHJJGAJSLGAHLSGHSAKBV AJHALHALHGLAGLHGBJVFBJVLFDHADAH GFJAGJAGAJFGAKGAKGFAK AJHFAGAKAGAGKAKAKGKAGFGJDGDJJDGJDJDFAG ... ... .... 100's of lines I would like to rearrange the content of this file so it will be a... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

7. Solaris

SSH weirdness

I've configured a new container/zone on Solaris 10 (Sparc) and I'm using Centrify for LDAP authentication to AD. My ssh client is as follows Sun_SSH_1.1.1, SSH protocols 1.5/2.0, OpenSSL 0x0090704f I'm seeing some strange behavior from ssh. When I ssh onto the new zone to myself (non-root... (2 Replies)
Discussion started by: CDM
2 Replies

8. IP Networking

ftp and ssh weirdness

i've just setup my desktop (ubuntu 8.04) to run vsftpd and sshd. i have two laptops, both running linux. on one laptop i can connect to the desktop via ftp and ssh and everything works fine. so i don't think there's a problem with the server. on the other laptop i can't connect to the desktop... (3 Replies)
Discussion started by: darkmatter14B
3 Replies

9. Shell Programming and Scripting

Joining lines in reverse. append line 1 to line 2.

Hi I have used many times the various methods to append two lines together in a file. This time I want to append the 1st line to the second and repeat for the complete file.... an example This is the file owns the big brown dog joe owns the small black dog jim What I want is ... (7 Replies)
Discussion started by: dwalley
7 Replies

10. UNIX for Dummies Questions & Answers

Joining lines to single line in VI

Dear friends, In VI, I have these data shown below: Line1 Line2 Line3 Line4 How can I JOIN these line to the first line? When I finished I should have: Line1 Line2 Line3 Line4 is there a text length limit of how long a single line can be in VI? Thank you much! (10 Replies)
Discussion started by: bobo
10 Replies
Login or Register to Ask a Question