can you expand on this? please bear with me I'm just learning:
grep -q "2007"; if [ $? -eq 0 ];
-q is option for what again?
[ $? -eq 0 ]; what does this break down to?
The man pages are your friends. Try
Specifically, in this case it means to be quiet. No output will be produced- the default is to print to the screen what grep finds. In your case, you don't want to see what it found, you just want to know what it found, and report it. The -q option is perfect for that.
Regardless, grep exits with a code. If it finds something, it exits with code 0 (which perhaps paradoxically means "success" in UNIX shell-land). That number is put into the "$?" variable. Also, the [ is the shell command "test". So
means "Test the $? variable and see if it's equal to 0". If so, the test command will exit with code 0 (success). The "if" command checks the exit code of the command it is given- in this instance, the "test" command. So if the test is successful, then do the "then" clause.
-mschwage
Hi all,
I have a file of the following format -
EXPRPT:SCN:1.1706E+10:SEQ_START:121652:SEQ_END:121664:0
( This file name is variable and changes daily)
Now in the same directory I have another set of files of the format -
EXPRPT.log.0001.0000121669
Now what I am trying to do is to ... (2 Replies)
here is a small script:
if ; then
echo please enter an argument
fi
if [ "$1" = "tom"; then
a=$1
echo $a
fi
here is my question. if the script name is j.sh and I run it : j.sh from shell prompt: without a parameter: it prints please enter an argument but if I go with . j.sh (current... (1 Reply)
Hi,
I am new to unix shell scripting. I just want a little script to check the no. of processes are equal to 8, then echo a successful message otherwise echo a unsuccessful message. Please help.
Thanks. (3 Replies)
The following Script takes each extension and determine what category it
belongs and then moves it into a directory based on the extension.
(for eg. 1.sh, 5.sh, 9.sh together; 4.csh, 120.csh, 6.csh together and 7.ksh, 2.ksh, 59.ksh together) and moves them to their respective directories viz.... (2 Replies)
#!/bin/ksh
for i in *.log*
do
ls $i|sed 's/\.log$//g' | while read file
do
echo "file $file is Running" >> lls.txt
echo "***************">> lls.txt
done
done
------------------------------------------------------------------
the output is :
file AdapterCCProvisioningInterface... (9 Replies)
Hello all,
i have a batmail process running on my machine(java process).
i just need a script we should detect whether the batchnail is running or not.If not it should restart it.
Can anyone assist me on this? (1 Reply)
Hello all, could somebody help..?
I have following 6 files (with white spaces in their names)
This is file
This is file1
This is file2
This is file3
This is file4
This is file5
This is file6
I tried to run the below script, and it did not give me desired ouput..
$ for i in `ls -1`
>... (7 Replies)
Hi I have the below file
Name=abc
Yr=2011
Mon=05
My script should be in such a way that whenever I run it then
Month should increment by 1 and if the month is 12 then when
I run the script then year should incremented by 1 and month
Should become 01(I.e jan)
Thanks for the help in... (6 Replies)
I am working on a CentOS release 6.4 server which has two mounted NAS devices, one with 20 x 3TB HDD running in FreeBSD with Zfs2 and one NAS which I don't know much about, but which has 7 HDDs in RAID-6.
I was running tar -zxvf on a tarball that is 80Mb with 50,000 small files inside. Even... (4 Replies)
Hi All,
In the below script, I am calling one sql file test.sql If this file returns any data then I have to generate this file test_$RUN_DATE.FCNA If the sql files returns no data then I dont want to generate this file test_$RUN_DATE.FCNA.
I tried one approach like: check the size of FCNA files... (1 Reply)
Discussion started by: praveenk768
1 Replies
LEARN ABOUT LINUX
service
service(8) System Manager's Manual service(8)NAME
service - run a System V init script
SYNOPSIS
service SCRIPT COMMAND [OPTIONS]
service --status-all
service --help | -h | --version
DESCRIPTION
service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working
directory set to /.
The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT. The supported values of COMMAND depend on the
invoked script, service passes COMMAND and OPTIONS it to the init script unmodified. All scripts should support at least the start and
stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start
command.
service --status-all runs all init scripts, in alphabetical order, with the status command.
EXIT CODES
service calls the init script and returns the status returned by it.
FILES
/etc/init.d
The directory containing System V init scripts.
ENVIRONMENT
LANG, TERM
The only environment variables passed to the init scripts.
SEE ALSO
/etc/init.d/skeleton,
update-rc.d(8),
init(8),
invoke-rc.d(8).
Jan 2006 service(8)