Thursday, June 20, 2013

[LINUX_Newbies] Re: Grep questions

 

On 20Jun2013 14:30, highskywhy@yahoo.de <highskywhy@yahoo.de> wrote:
| I start terminal:
|
| name@nameM57p:~$
|
| Is this the root?

No. It is your home directory, probably something like /home/name.
The command "pwd" will tell you ("print working directory").

| If you first cd to "/", the current directory
| would be the top of the tree and thus the search would be of all
| files. (At least, all files to which you have access.)
| *
| I do
| cd /
|
| name@nameM57p:~$ cd /
| name@nameM57p:~$
|
| Is this root?

Yes.

| A better command for your example might be:
|
| grep -r "thisismyAIM" . > resu.txt
|
| *
| grep -r "thisismyAIM" . > resu.txt
| Is this better then
| grep -r "thisismyAIM" * > resu.txt

Slightly. "*" will not match files/directories starting with a dot ("."),
like .ssh. That is a convention to "hide" configuration files as a matter of convenience.
It may be what you want, or it may not.

Searching * will missing the "dot" names.
Searching "." will read everything, starting at the current directory (which is called ".").

| which searchs the current directory downward, or:
| grep -r "thisismyAIM" / > resu.txt
|
| Is
| grep -r "thisismyAIM" / > resu.txt
| the smae like
| grep -r "thisismyAIM" * / > resu.txt

Same issue as above, yes. "dot" names versus all names.

| Is
| grep -r -i "thisismyAIM" * > resu.txt
| and
| grep -i -r "thisismyAIM" * > resu.txt
| the same?

Yes. For commands where options just turn "modes" on an off (-i,
-r) the order generally does not matter. For some commands the order
can matter: where different options overlap in the features they
control, or some rather dodgy commands where options and arguments
can be mixed on the line.

When in doubt, consult the manual page for the command (eg "man grep").

Cheers,
--
Cameron Simpson <cs@zip.com.au>

The trouble with fighting for human freedom is that one spends most of
one's time defending scoundrels. For it is against scoundrels that
oppressive laws are first aimed, and oppression must be stopped at the
beginning if it is to be stopped at all. - H.L. Mencken

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (14)
Recent Activity:
To unsubscribe from this list, please email LINUX_Newbies-unsubscribe@yahoogroups.com & you will be removed.
.

__,_._,___

No comments:

Post a Comment