[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

grep piping

Posted on 2009-03-30
2
Medium Priority
?
323 Views
Last Modified: 2012-05-06
#myScript.sh
cat cars.txt | egrep 'car1|car2'
   outputs: car1: 1a
                 car2: 1b
                 car1: 2d
                 car2: 2e

What I would like to accomplish is have an output like below using the minimal commands
1a with 1b
2d with 2e

Can I modify egrep output to match my format and do this all at once? Would you pipe to echo?

Before I do any manual processing I wanted to ensure there were no elegant unix ways of accomplishing this..


0
Comment
Question by:NewtonianB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 2000 total points
ID: 24026362
You description is confusing to me.

You can get the required output with:

egrep 'car1|car2' | cut -f2 -d: | paste -d' ' - - |sed "s/\(.*\) /\1 with /"
0
 

Author Closing Comment

by:NewtonianB
ID: 31564705
thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question