Wait/if Generated kind of operation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Wait/if Generated kind of operation
# 15  
Old 09-03-2014
Quote:
Originally Posted by RavinderSingh13
Dear linuxuser_

Could you please be more clear on your requirement, as I understood you are requesting for checking a file's existance. Let me give you an example for same.

Code:
if [[ -f "file2" ]] 
then 
echo 
"file2 is present."
else 
echo "file2 is NOT present." 
fi

In my case file is present so it will give following output. Also please refer man test for more information. Hope this helps.

Code:
file2 is present.

Thanks,
R. Singh
file will exist all the time and it will get update with data(like log file).
like push_back in cpp, data will be pushed into the file after every iteration.
I want to read Time value.
But trick is I want to read last two time occurrences and compare file existence.
If you see in my previous reply, last two time values are 2 and 3.
I want to check whether data files(these files are different) for
these time are present or not.

In the same case, since simulation is still going there will be no data files for time 3. After finished with 2nd simulation data some data will be written. but in log file I can see Time =3 as well which is not done yet.

Let me know if you still didn't understand.

Thanks for help.

---------- Post updated at 07:05 PM ---------- Previous update was at 06:56 PM ----------

Making my explanation even more simple:
How can I read last two occurrences of time value?
# 16  
Old 09-03-2014
Hello linuxuser_

Hope following example may help you(for bash). Here is a command named stat you can check by man stat for more information on same. Lets say we have 2 files named file2 and file33. Now let us compare their modify timings.

Code:
val1=`stat file2 | awk '/Modify/ {print $2}'`
echo $val1
2014-09-01
val2=`stat file33  | awk '/Modify/ {print $2}'`
echo $val2
2014-09-03
 
if [[ "$val1" == "$val2" ]]
then
echo "timings are equal."
else
echo "timings are NOT equal."
fi
timings are NOT equal.

Let me know if I can help further. By this we can compare the timings of files and check if files have been modified or not for today's date.

NOTE: I have tested this in bash environment.

Thanks,
R. Singh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calling a shell script in background and wait using "wait" in while loop

Hi, I am facing a strange issue, when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed. cat abc.txt | while read -u4 line do #if line contains #... (2 Replies)
Discussion started by: mihirvora16
2 Replies

2. Cybersecurity

What kind of hacking is going on here??

Connecting to the Internet with OpenVPN, the connection fails. Rerunning openvpn works second time round but the install is hacked at that point (e.g., a rogue 'java-security' update tries to install itself on 'yum update', yum however spots this and rejects the download, other basic things start... (3 Replies)
Discussion started by: GSO
3 Replies

3. Shell Programming and Scripting

Column operation : cosne and sine operation

I have a txt file with several columns and i want to peform an operation on two columns and output it to a new txt file . file.txt 900.00000 1 1 1 500.00000 500.00000 100000.000 4 4 1.45257346E-07 899.10834 ... (4 Replies)
Discussion started by: shashi792
4 Replies

4. Programming

A different kind of counting in SQL

I am looking to do a count on a database table where some of the elements count double. Say the data is as follows: id value 1 X 2 Y 3 X 4 X 5 Y A regular count (SELECT value, COUNT(*) FROM data GROUP BY value) would yield: X 3 Y 2 However, Y happens to count double so the answer should... (2 Replies)
Discussion started by: figaro
2 Replies

5. Infrastructure Monitoring

sed help,,kind of urgent!!

Hello All, My problem is: I want to replace a line from a file with sed. The first word in that line is always the same in every server. The second line is server model, which of course will vary from platform to platform and I need to leave that word as it is. After the second word, I need to... (3 Replies)
Discussion started by: solaix14
3 Replies

6. Shell Programming and Scripting

wait command - cat it wait for not-chile process?

Did not use 'wait' yet. How I understand by now the wait works only for child processes, started background. Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?) I need to start a background process, witch will be waiting... (2 Replies)
Discussion started by: alex_5161
2 Replies

7. UNIX for Dummies Questions & Answers

What kind of Linux for the newbies?

I am one of the newbies. I want to load linux on my notebook, however, i am not sure which linux is the most recommend for the newbies. Could you please advise? Thanks you very much for any advise you may give me. Best Regards, SANLEN (2 Replies)
Discussion started by: sanlen
2 Replies

8. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies

9. UNIX for Dummies Questions & Answers

Kind of weird question

I recently purchased a book titled Hacking: The Art of Exploitation. When I got it home I read the preface and found out that i shouldnt have bought it. It says the code examples in this book were done on an x86 based computer (I have a mac). Is there anything I can do to make my mac run similar to... (2 Replies)
Discussion started by: Cyberaxe
2 Replies

10. UNIX for Dummies Questions & Answers

what kind of UNIX

ok, so i want to figure out what type of UNIX i have and in this book im reading about it, it says that i can figure out what type i have by typing the command uname in the prompt. So i did this and it came up saying Darwin?? is that part of System V UNIX or BSD or do i have LINUX? if anyone can... (2 Replies)
Discussion started by: hiei
2 Replies
Login or Register to Ask a Question