The future of retail will be a combination of both online e-commerce and a brick-and-mortar retail presence as recent moves from both Walmart and Amazon have shown, including todays back-to-back announcements from the two rivals, which sees Amazon buying a chain of popular grocery stores with aWhole Foods deal for $13.7 billion, and Walmart picking up yet another online apparel vendor with Bonobos for $310 million.

Walmart is the only retailer with the size, scale and funds to take on Amazon, and its been making aggressive moves to compete with Amazons online business for years. Amazon, on the other hand, has been trying to figure out how to merge brick-and-mortar stores into its world of online shopping.

The question is, which retailer will figure out the perfect mix of online and offline, and get there the quickest?

As of late, Walmart been targeting Amazons Prime business launching free, two-day shipping on millions of items, without requiring an annual membership, for example. The move hasnt been lost on Amazon, which in turn has gone directly after the Walmart shopper, by making it easier for lower-income consumers to pay with cash on its site. It even discounted Prime for those on government assistance, arguing that a Prime membership is not a luxury, but a need.

The truth is, Amazon needs to capture the Walmart shopper as it has saturated the middle to high-end of the market with Prime memberships; approximately 60% of U.S. households now have Prime, with lower-income households the only place it can still grow Primestateside.

Beyond its Prime cash cow, Amazon has also made moves to better tackle the grocery business a tough area to compete as an online-only retailer, given the need to keep fresh items cold, and others frozen. Amazon has slowly ramped up in this area over the years via its delivery service AmazonFresh, but it has not been able to widely scale grocery deliveries due to the logistics and economics (or enormous money pit, more colloquially) involved with delivering perishable items.

Here, however, Walmart has an advantage. It has stores within 10 miles of 90% of American shoppers, and has quickly expanded its service that lets online customers place orders online to pick up curbside at their nearest store.Its even trialing drive-up grocery pickup kiosks, to make the process easier.

Amazon, on the other hand, is still a relative newcomer to brick-and-mortar retail, compared with Walmart. Though it just opened its own drive-up grocery pickup service in Seattle, many of its effort in brick-and-mortar feel more experimental.

For example,its trying outphysical bookstores in major markets around the U.S., which also double as a gadgets showcase as well as a test of using online purchase data to inform store inventory selections. Its also testing a new smart convenience store format with its cashier-free Go convenience stores, which could give it another angle into the grocery business.

But Amazon doesnt have the wealth of institutional knowledge about physical retail, much less real-world grocery stores, like Walmart does. Thats why it makes sense that its today making a huge grab for a grocery retailer like Whole Foods not only does that give Amazon the edge when competing against the likes of delivery startups like Instacart and Shipt in home grocery delivery (in fact it now owns a part of Instacart, thanks to Whole Foods), but it also gives Amazon a nationwide retail footprint to take on Walmart in grocery pickup.

As Amazon tries to figure out retail stores, Walmart is learning how to leverage its existing brick-and-mortar retail stores as a means of pulling customers away from Amazon. Walmart today isincentivizing online shoppers to drop by a store to pick up their items in order to lower the ticket price, and its nowturning its store staff into delivery drivers who can drop off online orders as soon as the next day.

What both retailers understand is that shopping will not fully transition online at least not in the foreseeable future; nor will it operate entirely offline, either. It needs to be a mix. There are times when people still want to shop out in the real world whether thats because they like the experience of seeing products in their hand, because it can be more convenient or even just quicker to just shop in a store at times, rather than searching a website and waiting for delivery.

While Amazon is putting up stores and now buying a whole host of them through Whole Foods, Walmart is figuring out how to make its online catalog more competitive. Ahead of todays Bonobos deal, its been making strategic acquisitions in one of the fastest-growing categories of online shopping apparel in addition to having beefed up its tech team by spending $3 billion on Jet.com, led by Marc Lore.

Lore, of course, is the entrepreneur crazy enough to take on Amazon not once, but twice first with Quidsi (Diapers.coms parent company), and then Jet. And Jets innovation in exposing the underlying logistics of online shopping through its Smart Cart technology which rewarded shoppers with savings for buying from nearby warehouses, or shipping items together, among other things has since been translated to Walmart through the new Pickup Discount program.

Both systems approach the problem of bringing the costs of e-commerce down by allowing the customer to make choices about what theyre willing to do to lower item prices. In Walmarts case, those choices are more about how to bring its retail stores into that equation.

In addition, through its Jet.com subsidiary, Walmart is snagging online businesses that can help it better compete with Amazon in areas where it may lack inventory. Jet acquiredacquired home goods store Hayneedle,a Zappos competitor called ShoeBuy, and clothing retailerModCloth, while its parent Walmart just last month bought outdoor retailer Moosejaw, which also has physical stores.

Several of these moves are about Walmart expanding its position in apparel, now the largest category for online retail, according tocomScore. Amazon has been approaching this category from another angle making its own-label fashion items, includingworkout clothing, bras, and mens shirts, for instance.

However, apparel sales are still challenging online, due to sizing issues, fit, and the high cost of managing returns. As Walmart inches into apparel through its combination of offline/online clothing shops, it can do things like offer try-on, pickup and returns of online apparel at local stores. Amazon, on the other hand, doesnt have a clothing retail presence. But maybe thats next, given how quickly these two are matching each others moves.

Read more: