The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Merging lines using AWK senthil_is Shell Programming and Scripting 6 03-05-2008 12:40 PM
Merging lines - Tuning the script senthil_is Shell Programming and Scripting 3 03-05-2008 03:24 AM
Merging files with AWK filtering and counting lines Meert Shell Programming and Scripting 2 01-28-2008 11:58 AM
merging two lines in a file thaduka UNIX for Dummies Questions & Answers 6 07-11-2007 09:27 AM
How to count lines - ignoring blank lines and commented lines kthatch UNIX for Dummies Questions & Answers 6 05-25-2007 01:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-18-2005
Foxgard Foxgard is offline
Registered User
  
 

Join Date: Jun 2005
Location: Czech rep.
Posts: 7
Question Merging lines into one

Hello. I would be very pleased if sb. help me to solve my problem. I've got a file with many non blank lines and I want to merge all lines into one not destroy the informations on them. I've tryed it with split and paste, tr, sed , but everything I've done has been wrong. I know about crazy solution but I don't want to do it this way. Don't forget the simplier way is the better. Thaks

Last edited by Foxgard; 06-18-2005 at 06:46 PM..
  #2 (permalink)  
Old 06-18-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
tr -d '\n' < file
  #3 (permalink)  
Old 06-18-2005
Foxgard Foxgard is offline
Registered User
  
 

Join Date: Jun 2005
Location: Czech rep.
Posts: 7
Misunderstanding

You don't understand me. I've filled up my problem with red-coloured text to U understand me. Your solution only deletes all the newlines "\n". And that I didn't want to do with the file.
e.g.
from
A
B
C
into
ABC
  #4 (permalink)  
Old 06-18-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
How is that different from deleting the newline characters?
  #5 (permalink)  
Old 06-19-2005
Foxgard Foxgard is offline
Registered User
  
 

Join Date: Jun 2005
Location: Czech rep.
Posts: 7
I see how you want it to work, but it doesn't work. When I send the command to bash, it deletes all the lines from input. I've had some problems with intepretation of the commands even if the command was standard before. I use the xandros 3.01,GNU bash version 2.05b.0(1)-release (i386-pc-linux-gnu). May the problem be in my OS?
  #6 (permalink)  
Old 06-19-2005
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
Code:
$ cat > test.txt
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Code:
#!/bin/bash
#
# append.sh
#
while read line ; do
    printf ${line}
done < $1

Code:
$ ./append.sh test.txt
abcdefghijklmnopqrstuvwxyz
$ tr -d '\n' < test.txt
abcdefghijklmnopqrstuvwxyz
$ awk '{prinf $0}' file.txt
abcdefghijklmnopqrstuvwxyz
  #7 (permalink)  
Old 06-19-2005
Foxgard Foxgard is offline
Registered User
  
 

Join Date: Jun 2005
Location: Czech rep.
Posts: 7
Unhappy

Code:
bash:cat /tmp/test$$ -prints this
#define hcv 54
 #define f 8
  #define s 354
 jae
 feh
  h
  f*h
  adssfh
#the whole code isn't necessary to read only the output of cat /tmp/test2$$ and output of file$$
Code:
bash:sed "/#define.*/w /tmp/test$$" test ; sed '{s_[/t ]*#define[\t ]\+\(\<.\+\>\)[\t ]\+\(\<.\+\>\)_\{s/\1/\2/\};_}' /tmp/test$$ > /tmp/test2$$ ; cat /tmp/test2$$ | tr -d '\n' > file$$; cat file$$ -prints nothing
bash:cat /tmp/test2$$ - prints that should print
{s/hcv/54/};
{s/f/8/};
{s/s/354/};
This is the whole problem I've got and I don't understand why It doesn't work
*mistake by rewriting the code to here, because I read in my code the name of the file from $prom, now it is right

Last edited by Foxgard; 06-19-2005 at 07:34 AM..
Sponsored Links
Closed Thread

Bookmarks

Tags
linux, linux commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0