- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Concatenation of 2 Files
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
11-07-2004 07:49 PM
11-07-2004 07:49 PM
Maximum points to all correct reply!
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2004 07:59 PM
11-07-2004 07:59 PM
Re: Concatenation of 2 Files
sed -n '2,$p' file2 >> file1
Of course there are lots of ways to do the cat without line 1...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2004 08:05 PM
11-07-2004 08:05 PM
Re: Concatenation of 2 Files
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2004 09:11 PM
11-07-2004 09:11 PM
Re: Concatenation of 2 Files
awk '{ if (NF!=1) print $0 }' file2 >> file1
If you want to remove duplicate lines in file2 compared to file1 then,
grep -vf file1 file2 >> file1
HTH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2004 09:44 PM
11-07-2004 09:44 PM
Re: Concatenation of 2 Files
The grep is also dangorous. If file1 contains a line consisting of a part of a line of file2, those are skipped when adding file2.
Example: file1 contains 2 lines:
aaa
bba
file2 contains following lines:
aaaa
bbbb
bbba
Now only line 2 would be added with the grep...
If the resulting order is not important, a simpler solution would be in that case:
sort -u file1 file2 > file3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2004 10:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2004 07:01 AM
11-08-2004 07:01 AM
Re: Concatenation of 2 Files
awk 'NR>1{print $0}' file2 >> file1
for just the second line, it would be:
awk 'NR==2{print $0}' file2 >> file1
Oz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2004 07:51 AM
11-08-2004 07:51 AM
Re: Concatenation of 2 Files
Given two files:
$ cat file1
aaa
bbb
ccc
ddd
$ cat file2
aaa
eee
fff
$ comm -13 file1 file2 >>file1
...this would append all lines that appear ONLY in file2 to the end of file1...
$ cat file1
aaa
bbb
ccc
ddd
eee
fff
...continuing the example...
$ cat file3
aaa
bbb
ccc
ggg
$ comm -13 file1 file3 >>file1
$ cat file1
aaa
bbb
ccc
ddd
eee
fff
ggg
...shows that since file3 and file1 both contain lines aaa, bbb and ccc, only line ggg from file3 is appended.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2004 01:44 PM
11-08-2004 01:44 PM