Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I determine what line in a file a search term is found?

Posted on 2008-06-09
2
Medium Priority
?
228 Views
Last Modified: 2013-12-27
I know I can cat a file to see it's contents, wc -l a file to count the number of lines in said file, and | grep value a file to search for value within the file.

I'd like to be able to search a file for a term, then display the line number of the file that it was found in, if at all possible.

Situation: I have an application that's processing (importing data from) a text file, and I'd like to see how far along it is.  There are 28000 some lines in said text file, and there's no practical logging setup within the application to tell me where it's at, so I need to find an entry in the DB that I know was added via the process, and then find where in the file that line exists - if that makes any sense.

I need to do this in the shell, and I'd prefer that not much (or any) scripting be necessary.  I can also not install anything, as I'm a user on a production server instance that's locked down, so I need to use native applications to get the job done.

I only know that I'm on a Unix like operating system.  It may be Solaris, it may be RHEL.  Don't know how to find out at the moment - and hoping it won't matter too much.
0
Comment
Question by:techport13
[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: 21748640
grep -n "some term" file
0
 

Author Closing Comment

by:techport13
ID: 31465629
Exactly what I was looking for.  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

Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

718 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