LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-23-2015, 05:26 AM   #1
murali2489
LQ Newbie
 
Registered: Jan 2015
Posts: 14

Rep: Reputation: Disabled
Please interpret the meaning of this command


Hi ,

Please explain what the below command means ..


Code:
if grep -c -i Y $INIFILE > /dev/null
I know what is the use of grep, it is used for finding a character or string in a file. But i could not understand the above form of grep command.

I am new to linux so this might be a simple question, but please throw some light on it.


Edited

And also please explain why they are creating a file in null in the below command

Code:
cat /dev/null > $DATA_DIR/$DATAFILE

Last edited by murali2489; 03-23-2015 at 05:29 AM.
 
Old 03-23-2015, 05:31 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,124

Rep: Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271
so check man grep:
Code:
grep [OPTIONS] PATTERN [FILE...]
...
-c, --count
      Suppress  normal  output;  instead  print a count of matching lines for each input file.  With the -v, --invert-match option (see below), count non-
      matching lines.  (-c is specified by POSIX.)

-i, --ignore-case
      Ignore case distinctions in both the PATTERN and the input files.  (-i is specified by POSIX.)

EXIT STATUS
       The exit status is 0 if selected lines are found, and 1 if not found.  If an error occurred the exit status is 2.  (Note: POSIX error handling code  should
       check for '2' or greater.)
if will check the exit status
> means redirection, see man bash about that


http://earthwithsun.com/questions/84...r-log-messages

Last edited by pan64; 03-23-2015 at 05:37 AM.
 
1 members found this post helpful.
Old 03-23-2015, 05:41 AM   #3
murali2489
LQ Newbie
 
Registered: Jan 2015
Posts: 14

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
so check man grep:
Code:
grep [OPTIONS] PATTERN [FILE...]
if will check the exit status
> means redirection, see man bash about that


http://earthwithsun.com/questions/84...r-log-messages

Thanks Pan64

In the page I could not see how "Y" is used in the command.

and also please tell why they are creating a file inside dev/null in
Code:
 cat /dev/null > $DATA_DIR/$DATAFILE

Last edited by murali2489; 03-23-2015 at 05:42 AM.
 
Old 03-23-2015, 05:52 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,124

Rep: Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271
Y is the pattern in this case. That means (in short) you want to look for the letter Y
I sent you a link too about that cat command, but first you need to understand how redirection works (that is not a file inside dev/null), see man bash or http://www.catonmat.net/blog/bash-on...ed-part-three/, http://www.tldp.org/LDP/abs/html/io-redirection.html

(if you really want to say thanks just press YES)
 
1 members found this post helpful.
Old 03-23-2015, 06:05 AM   #5
murali2489
LQ Newbie
 
Registered: Jan 2015
Posts: 14

Original Poster
Rep: Reputation: Disabled
Thanks Pan64 for the link and advise !!!

one final question,

In the below if statement, please tell what condition is checked..

An abstract idea is enough, Im seeing this script for understanding.

Code:
if $EXENAME -fi$DATA_DIR/$DATAFILE > $LOG_DIR/info.log
Please tell me when this condition tends to be true...

Thanks in Advance...
 
Old 03-23-2015, 07:03 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,124

Rep: Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271Reputation: 2271
usually the condition is located between the keywords if and then, so I'm not really sure what to say (your examples are not complete). See again the man page of bash:
Code:
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
        The  if  list  is  executed.  If its exit status is zero, the then list is executed.  Otherwise, each elif list is executed in turn, and if its exit
        status is zero, the corresponding then list is executed and the command completes.  Otherwise, the else list is executed, if present.  The exit sta‐
        tus is the exit status of the last command executed, or zero if no condition tested true.
EXENAME is a variable and I have no idea what is stored in it. Probably that is an executable. All the other things will be handled/evaluated by that program (and again, > means redirection).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What is meaning of top command redhatwannabe Linux - Server 1 02-27-2014 01:42 AM
how Command interpreter understand the meaning of command tushar_pandey Linux - Newbie 5 08-21-2012 05:25 PM
How do I get bash not to interpret the output of a backquote command? curieux Linux - General 1 10-13-2010 09:23 AM
How to interpret readings using TOP command? tracy_nss Linux - General 2 08-02-2010 09:14 PM
command meaning ramrann Linux - Newbie 2 10-18-2005 02:56 PM


All times are GMT -5. The time now is 02:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration