I have a file which keeps on appending the data continuously, i that i am looking for a particular pattern, if i dont find that pattern i want to wait for 30 seconds to check it again.
can we use it like this
-----------------------------
until [ $? -eq "0" ]
do
cat $line | tail -5 | grep 'PATTERN' > /dev/null
sleep 30
done
echo "File Contains the pattern 'PATTERN' now"
------------------------------------------------------
i am not able to get it, even if pattern is not there it is coming out of loop and executing echo command in any case.
First off, you should post ALL of the code, not just a snippet of the until loop. Based on your post, I have no clue what "$line" is.
Second, please use the code box/tags for your code...thats the little "#" icon near the top right of the toolbar when you are making a post.
Third, the reason that your loop is exiting is that "$?" was 0 when you started the loop. Its kinda like saying this:
the command ./stuff will never run.and even if "$?" was not 0 to start off the loop, the "sleep 30" command would certainly have a 0 exit status.
So, what you probably want to do is something like this:
You do not really have to do a test/comparison (i.e. [ 1 -eq 1 ]) with a while, or until loop, as it just evaluates the exit status of the command after "until". Believe it or not, the square bracket comparison is actually a command (its the "test" command).
Last edited by Gee-Money; 06-23-2009 at 10:05 PM..
Guys I placed
#!path/awk -f
placed awk script
and used $1 to call 1st inputfile inside the script.
But some where I did mistake. Could you please help me run this script as executable
I forgot to mention I also used BEGIN before placing awk script. But nothing worked out.
Script
... (2 Replies)
Hi guys,
I'm a little stuck on this problem, I've tried googling it and some trial and error but can't seem to get it working.
Basically I need the script to:
1) create a directory called "mybackups", if it doesn't exist
2) go through all the .sh files in the current directory, and copy... (4 Replies)
Dear all
I am bit new to shell scripting . I am implemented autossh between two sun solaris machines , so that when I use sftp it will not ask for the password.
Now I need to make shell script in which I have to transfer files from one server to another server automatically through root... (8 Replies)
Hi Friends,
I'mfacing a problem while doing ftp of a large file.The control session is getting closed after sometime.But data session transfers the file successfully even when the control seeion is lost.I need to make the control session available as long as data session is active.
How can i... (1 Reply)
Dear all
I am facing one problem which is related to enabling Autossh between windows and solaris machine. If suppose their are two servers, server A is having windows and server B is having Solaris.I install openssh server software for windows through sourceforge.net site. What my requirement... (7 Replies)
Dear all
I am bit new to programming. I have to redirect the output to a file which will be in the following format
man ls> date +"hup-%m%d%y-%H%M" --------> this will show me the month,day,year,hours and minute in a file name whose name start from "hup-"
kindly any correct my syntax (2 Replies)
Dear all
Dear Brother
I am bit new to programming or shell scripting. I have given one shell script which is regarding combining all the 240 or less files in a particular folderwhich is related to one hour of the day. There will be 24 these kind of folders related to a day . It means there... (4 Replies)
Hi Everybody,
I am trying to make the ddd-3.3.9 debugger. I installed all dependencies.
this is what i get:
# make
Making all in themes
make: Entering directory `/space/atoulan/ddd-3.3.9/themes'
make: Nothing to be done for `all'.
make: Leaving directory... (0 Replies)