Friday, October 21, 2011

UNIX: Searching within the file

What is the command to go to 10th line of the given file?
10G

Will 10g works?
No. Remember in UNIX case sensitive matters.
Then what happens if you enter G alone?
The cursor will go to last line of your file.

Search for a pattern in the file
Enter '/', will take you to the end of the file and then provide the patter to search...

primary players. Each is a little different from the other.) Another contributor to the sprawl
of modern UNIX is the energy of the UNIX programming community; plenty of UNIX users
decide to write a new version of a command in order to solve slightly different problems, thus
spawning many versions of a command.
C
/



primary players. Each is a little different from the other.) Another contributor to the sprawl
of modern UNIX is the energy of the UNIX programming community; plenty of UNIX users
decide to write a new version of a command in order to solve slightly different problems, thus
spawning many versions of a command.
C
/decide



primary players. Each is a little different from the other.) Another contributor to the sprawl
of modern UNIX is the energy of the UNIX programming community; plenty of UNIX users
decide to write a new version of a command in order to solve slightly different problems, thus
spawning many versions of a command.
C
/decide



To find next occurence press "n"


Here also the case matters. If you type "DECIDE" after the search command "/" UNIX will look for "DECIDE" not "decide"


What if I need to search backward
ans:
use the command ?
primary players. Each is a little different from the other.) Another contributor to the sprawl
of modern UNIX is the energy of the UNIX programming community; plenty of UNIX users
decide to write a new version of a command in order to solve slightly different problems, thus
spawning many versions of a command.
C
?decide



Now when you enter command "n" it will search backward!!

****
Hope this is helpful. Thanks Phoenix...

No comments:

Post a Comment