- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to join multiple lines into single line?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 12:55 PM
05-10-2002 12:55 PM
I know that this can be done with sed or awk, but I am newbie so not very familiar with these utilities. Any help is appreciated.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 02:04 PM
05-10-2002 02:04 PM
Re: How to join multiple lines into single line?
If you don't like perl, then use the echo command to do the trick:
# echo `cat $MULTIPLE_LINES_TO_JOIN_INTO_ONE`
$MULTIPLE_LINES_TO_JOIN_INTO_ONE is a variable which contains the filename to cat and subsequently contents echo'ed.
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 03:54 PM
05-10-2002 03:54 PM
Re: How to join multiple lines into single line?
Do this:
sed 's/$/stringyouwouldliketoinsert/' testfile | tr -s "\n" " " > testfile.out
Will insert the variable at the end of the each line and will strip all new lines to one space.
Hope this helps !
P.S. cat filename | tr -d "\n" will strip all new lines in a file
Thanks,
Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 10:39 PM
05-10-2002 10:39 PM
Re: How to join multiple lines into single line?
the last tr command does not work correctly on control characters I think it should have been
cat filename | tr -d '[\012]' > newfile
regards
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2002 10:46 PM
05-10-2002 10:46 PM
Re: How to join multiple lines into single line?
just checked it and this works
#
# cat /tmp/testfile
date
date
date
date
date
date
date
#
# sed 's/$/ my_defined_variable /' /tmp/testfile | tr -d '[\012]'
date my_defined_variable date my_defined_variable date my_defined_variable date my_defined_variable date my_defined_variable date my_defined_variable date my_defined_variable #
#
cheers
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2002 09:00 AM
05-13-2002 09:00 AM
Re: How to join multiple lines into single line?
Mr. Carr and Mr. Khan solution accomplish 90% of what I wanted to do, but the value of my pre-define variable did not get inserted into the outfile. Example, Z="myvaluehere", when I do:
%sed 's/$/O/' ...
the O gets inserted in the outfile, not the string myvaluehere.
Perhaphs I am doing something wrong, maybe my syntax is incorrect?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2002 09:02 AM
05-13-2002 09:02 AM
Re: How to join multiple lines into single line?
Correction:
Example, Z="myvaluehere", when I do:
%sed 's/$/Z/' ...
the Z gets inserted in the outfile, not the string myvaluehere.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2002 09:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2002 10:00 AM
05-13-2002 10:00 AM
Re: How to join multiple lines into single line?
Procura's posting should help solve the remaining 10% of your problem.
PS. N/A for this one..
Thanks,
Shabu