- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Merging two files or three files in column wise.
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
08-24-2005 03:39 AM
08-24-2005 03:39 AM
i have 3 files say file1,file2, file3
one file is having only counters, say file1
the next two files (file2,file3) have the values for the counters of file1.
now i want to merge all the files so that i will get
file1 file2 file3
counter value1 value2
there are lots of counters like this.
and paste command failed to do this.
thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:43 AM
08-24-2005 03:43 AM
Solutioncat file1 |while read counter ;do
cat file2 |while read value1 ;do
cat file3 |while read value2 ;do
echo "$counter $value1 $value2" >>outfile
done
done
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:54 AM
08-24-2005 03:54 AM
Re: Merging two files or three files in column wise.
Tried your command but it failed.
it gone on loop and it is not ending at all
now i tried with 2 files only.
the output was like this
counter1
counter2
counter3
value1
value2
value3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 04:00 AM
08-24-2005 04:00 AM
Re: Merging two files or three files in column wise.
eg:
create file1 containing
111
222
333
444
file2 containing
aaa
bbb
ccc
ddd
file3 containing
zzz
yyy
xxx
www
running "paste file1 file2 file3" gives the tab-separated output
111 aaa zzz
222 bbb yyy
333 ccc xxx
444 ddd www
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 04:02 AM
08-24-2005 04:02 AM
Re: Merging two files or three files in column wise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 04:08 AM
08-24-2005 04:08 AM
Re: Merging two files or three files in column wise.
the problem was there in my command..
cris and alan it worked file thank you
thanks a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 04:17 AM
08-24-2005 04:17 AM
Re: Merging two files or three files in column wise.
echo "f1 f2 f3"
x=1
cat f1 |while read counter[$x] ;do
(( x = x + 1 ))
done
x=1
cat f2 |while read value1[$x] ;do
(( x = x + 1 ))
done
x=1
cat f3 |while read value2[$x] ;do
(( x = x + 1 ))
done
(( max = x - 1 ))
x=1
while [ "$x" -le "$max" ] ;do
echo ${counter[$x]} ${value1[$x]} ${value2[$x]}
(( x = x + 1 ))
done