- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Merging file 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
12-24-2004 03:41 PM
12-24-2004 03:41 PM
Merging file lines
ex:
My name is sam
her name is judy
his name is blabla
its name is cat
My name is sam
her name is judy
his name is blabla
its name is cat
I want the result to be:
My name is sam:her name is judy:his name is blabla:its name is cat
My name is sam:her name is judy:his name is blabla:its name is cat
Please help urgent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2004 04:34 PM
12-24-2004 04:34 PM
Re: Merging file lines
I don't know why u have this in your profile:
"I have assigned points to 0 of 64 responses to my questions"
Go thr' this link below:
http://forums1.itrc.hp.com/service/forums/helptips.do?admit=716493758+1085211538437+28353475#33
Hope that helps.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2004 04:50 PM
12-24-2004 04:50 PM
Re: Merging file lines
I couldnt follow please explain more
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-24-2004 08:38 PM
12-24-2004 08:38 PM
Re: Merging file lines
Is this forum for fooling or what?
Keep your nose away if you dont have any answer?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2004 12:40 PM
12-25-2004 12:40 PM
Re: Merging file lines
You don't, and I guess that's why he gave You no answer. (And I agree on that)
I myself don't know the short and professional regex - based way, but You could also do something like
script.ksh < input
with script.ksh like
while read content
do
#set -x
if [ "X$content" = "X" ]
then
echo $result
unset result
else
result="${result}:${content}"
fi
done
addionally learn to say thanks, unless You really enjoy people being unwilling to help You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2004 03:21 PM
12-25-2004 03:21 PM
Re: Merging file lines
I appreciate your help, but i found better answer in sed $ awk nutshell book already.
I have never had the manner of not thanking people who helped me.But, it disturbs me to feel that some one is pretending to be smart like Katkat
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2004 08:29 PM
12-25-2004 08:29 PM
Re: Merging file lines
Good to know you got your answer.
Please cool down, as the text do not portray the real expressions the writer had. There was no wrong intention in that post.
Please do call me on my mobile 050-4683550 if you need to talk to me. The Forum is to help each other anyway.
With regards,
Mohan
Emitac.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 04:16 PM
12-26-2004 04:16 PM
Re: Merging file lines
muthu # cat junk
My name is sam
her name is judy
his name is blabla
its name is cat
My name is sam
her name is judy
his name is blabla
its name is cat
muthu # awk '!/^$/ { print $0 }' junk | awk '{ if ( NR % 4 != 0) {printf $0":" } else {printf $0"\n"} }'
My name is sam:her name is judy:his name is blabla:its name is cat
My name is sam:her name is judy:his name is blabla:its name is cat
awk is useful to do this effectively.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 04:16 PM
12-26-2004 04:16 PM
Re: Merging file lines
I realize you have thanked helpers before as you have indeed thanked me: http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=753008
However, this is not immediately obvious to all.
You may want to consider just going with the flow and use the 'points' system to indicated how helpful/useful a particular reply was. It is short and concise, and does not 'waste' bandwith by bringing topic back to the top. It helps some (like me) to decide whether to go into a 'still open' topic. An explicit thank-you remains welcome of course in a 'closing' reply where you, as the author, mark the entire topic as 'done'.
Also, for the curious folks amongst us, you may want to indicate your final solution (for our education), and/or problems with prior solution (like Heigl's script having a leading ":").
fwiw... I'd solve it in perl.
If a trailing ":" is acceptable:
perl -pe 'chop; $_ .= (/^$/)? "\n" : ":"' input
-p = loop and print $_ at end of loop
chop = take of last character from $_ (newline)
$_ .= = append the following to $_
($/^$) = empty line?
? "\n" = if empty add a newline
: ":" = if not then add a colon
As specified:
perl -ne 'if (/^$/){chop $line; print "$line\n"; $line=""} else {chop; $line .= $_ . ":"} ' input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 05:38 PM
12-26-2004 05:38 PM
Re: Merging file lines
It was for your betterment i gave you that advice and honestly i was not able to answer your tricky question in limited time i had and i was curious about the replies that will be coming up.
Now when you go on inetractive by assigning points and making others realize the depth of thier solution they can further help you better.
There was nothing sarcastic in by reply which made you so irritating. Well, it happens when person is in problem start doubting everybody and in negative way.
My intention was to speed up the responses to your question thereby getting you quick help.
1. "Helps in the sense of what?
Is this forum for fooling or what?
Keep your nose away if you dont have any answer? "
Ans.. I had already kept my nose out because i know my limits and depth of knowledge. Secondly even if i was wrong or i had misbehaved how can you directly blame the entire forum that shows how week you are in concluding things.
2. "I have never had the manner of not thanking people who helped me.But, it disturbs me to feel that some one is pretending to be smart like Katkar."
Ans.. DOn't get disturb without knowing the facts and for the later part i have already told you how fast and wrong you are in your conclusion.
I am helpless if you are not able to understand my intentions.
I wish you all the best.
Bharat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 06:08 PM
12-26-2004 06:08 PM
Re: Merging file lines
GO thr' this thread below :
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=553711
Bharat had actively helped you there and it's unfortunate see your comments in this thread. He tried to help you out there and you even didn't care to give any feedback on it, forget about assiging points ( it's not at all compulsory)
Girish....