- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting help, joining two lines
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
10-16-2001 07:49 AM
10-16-2001 07:49 AM
Oct1620018:20AM
va_q5n
Oct1620018:17AM
va_qeq
Oct1620018:28AM
va_qv7
Oct1620018:10AM
va_rq4
Oct1620018:19AM
va_rw1
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2001 08:01 AM
10-16-2001 08:01 AM
Solution1) paste:
paste -s -d " \n"
will join the files with a space between the lines
2) awk
awk '{ first=$0; getline; print first $0 }'
Potentially you can use pr, join or sed to do this too...
dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2001 08:01 AM
10-16-2001 08:01 AM
Re: Scripting help, joining two lines
# awk '{if (NR%2==1) {HOLD=$0} else {print HOLD,$0}} END {if (NR
%2==1) {print HOLD}}' /tmp/myfile > /tmp/myfile.new
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2001 08:17 AM
10-16-2001 08:17 AM
Re: Scripting help, joining two lines
Once again thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2001 08:18 AM
10-16-2001 08:18 AM
Re: Scripting help, joining two lines
How about purely in the shell reading from stdin, outputing to stdout:
#!/usr/bin/sh
N=0
SAVE=""
cat - | while read X
do
if [ $((${N} % 2)) -eq 0 ]
then
SAVE=${X}
else
echo "${SAVE} ${X}"
fi
N=$((${N} + 1))
done
exit 0
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2001 08:58 AM
10-16-2001 08:58 AM
Re: Scripting help, joining two lines
while read line
do
read line2
print "${line}${line2}"
done
So, can anybody make a shorter version using just builitins?
dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2001 09:55 AM
10-16-2001 09:55 AM