?
Solved

Searching an Argument

Posted on 2006-06-02
7
Medium Priority
?
340 Views
Last Modified: 2010-04-21
Hi

I am using a more command on doing a search on a string argument.

Below is what I am doing

more "filename" |  grep "Argument"

But this is only giving me the specific argument only in the file.

What I want to do is I want to get the Argument and from there I want to move forward in the whole file

"that means I want to get argument and from there I should the start reading the file."

I hope I made by question clear.

Is there any command which allows me to do that..

Thanks

Ruby
0
Comment
Question by:ruby_srinivas
5 Comments
 
LVL 23

Accepted Solution

by:
brettmjohnson earned 172 total points
ID: 16818514
use 'less' instead of 'more', since less provides searching capability:

  less -p "Argument" "filename"

will start viewing the file "filename" from the first occurrence of "Argument".
0
 
LVL 6

Assisted Solution

by:bira
bira earned 164 total points
ID: 16818878
try this way

line=`fgrep -n "argument"  filename | cut -f1 -d':'|head -1`
tail +$line yourfile
0
 
LVL 20

Assisted Solution

by:Gns
Gns earned 164 total points
ID: 16829998
if you have awellbehaved more, it can actually do:
more +/Argument filename
which would acomplish the task... in mores old and quirky way:-). The line containing the pattern (Argument) would be the third from the top...

-- Glenn
0
 
LVL 6

Expert Comment

by:JJSmith
ID: 16881264

Fire up more and use /string to find a string; note use just / to find the same string again. This / is a command - not the +/ option on the more command line.


$  more filename

/string


Cheers
JJ
0
 
LVL 20

Expert Comment

by:Gns
ID: 16883649
JJ, this is exactly the same ... The "+...." syntax is just to "jumpstart" more with a command... Completely analogous with other paginators... And it fits with the initial Q;-)

-- Glenn
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 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