473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

A little help with file searching and text processing

I'm not the most experienced when using unix commands and have come across a little problem.
I have a very simple database (named a1.db) set up like this:
name address phone#
name1 address1 phone1

where each field is separated by a tab ("\t").
Now what i wanted to do is search the name column for a match using grep, and came up with "cut -f1 a1.db | grep name1" and that works fine. However when it finds a match i wanted it to print the whole line rather than just the part that was cut. So instead of the out put being "name1" on a match, I'd like it to be "name1 address1 phone1" without complicating things too much.

Hope you understand what i mean. Any help is very much appreciated.
Thanks
Feb 23 '07 #1
1 1331
Motoma
3,237 Expert 2GB
I'm not the most experienced when using unix commands and have come across a little problem.
I have a very simple database (named a1.db) set up like this:
name address phone#
name1 address1 phone1

where each field is separated by a tab ("\t").
Now what i wanted to do is search the name column for a match using grep, and came up with "cut -f1 a1.db | grep name1" and that works fine. However when it finds a match i wanted it to print the whole line rather than just the part that was cut. So instead of the out put being "name1" on a match, I'd like it to be "name1 address1 phone1" without complicating things too much.

Hope you understand what i mean. Any help is very much appreciated.
Thanks
Expand|Select|Wrap|Line Numbers
  1. $ grep -i "Johnathan Doe" a1.db
  2.  
Feb 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roberto Dias | last post by:
Hi, I've got a text file and I need to capture some data in it. I implemented ( using comp.lang.c++ help) a typical searching algorithm that first find the header (label that identifies the data...
5
by: B. Williams | last post by:
I need some assistance with random access file processing. I have a function that I would like to change from sequential file processing to random access. Thanks in advance. void...
7
by: Trevor | last post by:
I have created a small DB in Access, I then created the datasource and got the data through to the app in detail and it shows me 6 columns and each of the 6 columns holds a number. I then have a...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.