03-22-2016
I don't know the full scope of your problem, but maybe this approach fits: Have one specific file which holds the "highest number used so far". When you need to create a new sequence number, just increment (the content of) this file and use the new number. The only thing to take care of - but this applies to each possible solution - is concurrency: If two processes try to do the same, you have a race condition. Therefore you should lock the file, while using it.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Folks !!!!!!!!!!!!!!!!!!!
My Requirement is.............
i have a input file:
501,501.chan
502,502.anand
503,503.biji
504,504.raja
505,505.chan
506,506.anand
507,507.chan
and my o/p should be
chan->3
i.e. the word which occurs maximum number of times in a file should be... (5 Replies)
Discussion started by: aajan
5 Replies
2. Shell Programming and Scripting
Hi all,
I have a file with lines written somewhat like this.
aaaa
ccc
aa
linux
browse = no
xssxw
cdcedc
dcsdcd
csdw
police
dwed
dwd
browse = no
cdecec (2 Replies)
Discussion started by: vikas027
2 Replies
3. Shell Programming and Scripting
File having data in following format :
file name : file.txt
--------------------
111111;name1
222222;name2
333333;name3
I want to read this file so that I can split these into two paramaters i.e. 111111 & name1 into two different variables(say value1 & value2).
i.e val1=11111 &... (2 Replies)
Discussion started by: sjoshi98
2 Replies
4. UNIX for Dummies Questions & Answers
Hi, i am new to unix shell scripting and i need a script which would search for a particular word in all the files present in a directory. The output should have the word and file path name. For example: "word" "path name".
Thanks for the reply in adv,:) (3 Replies)
Discussion started by: virtual_45
3 Replies
5. Shell Programming and Scripting
Hi Everyone,
I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap".
For Example:
In the Directory,
$pwd
/home/nick
$ grep -l "xsgd1234dap" *.sh | wc -l
119
I have "119" files that are still using... (5 Replies)
Discussion started by: filter
5 Replies
6. UNIX for Dummies Questions & Answers
I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL.
I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies
7. Shell Programming and Scripting
hi all, I'm new there, I'm just playing with perl and lwp and I just successfully created a script for log in to a web site with post. I have a response but I would like to have something like this:
I have in my response lines like:
<div class="sender">mimi020</div>
<some html code.....>... (3 Replies)
Discussion started by: vogueestylee
3 Replies
8. Shell Programming and Scripting
HI,
Can you tell me how to find the number of digits in a word.
$cat data.txt
+123456ad
87645768
Output should be
6
8 (5 Replies)
Discussion started by: ashwin3086
5 Replies
9. Shell Programming and Scripting
Hi All,
I have a XML file which is looks like as below. <<please see the attachment >>
<?xml version="1.0" encoding="UTF-8"?>
<esites>
<esite>
<name>XXX.com</name>
<storeId>10001</storeId>
<module>
... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies
10. Shell Programming and Scripting
example:
i have the following text file...
i am very tired.
i am busy
i am hungry
i have to find the number of occurence of a particular word 'am' from the text file.. can any one give the shell script for it (34 Replies)
Discussion started by: sheela
34 Replies
LEARN ABOUT OSF1
msem_unlock
msem_unlock(3) Library Functions Manual msem_unlock(3)
NAME
msem_unlock - Unlocks a semaphore
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <sys/mman.h>
int msem_unlock ( msemaphore *sem, int condition );
PARAMETERS
Points to an msemaphore structure which specifies the semaphore to be unlocked. Determines whether the msem_unlock() function unlocks the
semaphore if no other processes are waiting to lock it.
DESCRIPTION
The msem_unlock() function unlocks a binary semaphore.
If the condition parameter is 0 (zero), the semaphore is unlocked, whether or not any other processes are currently attempting to lock it.
If the condition parameter is MSEM_IF_WAITERS, and another process is waiting to lock the semaphore or it cannot be reliably determined
whether some process is waiting to lock the semaphore, the semaphore is unlocked by the calling process. If the condition parameter is
MSEM_IF_WAITERS, and no process is waiting to lock the semaphore, the semaphore will not be unlocked and an error will be returned.
All calls to the msem_lock() and msem_unlock() functions by multiple processes sharing a common msemaphore structure behave as if the calls
were serialized.
If the msemaphore structure contains any value not resulting from a call to the msem_init() function followed by a (possibly empty)
sequence of calls to the msem_lock() and msem_unlock() functions, the results are undefined. The address of an msemaphore structure may be
significant. If the msemaphore structure contains any value copied from an msemaphore structure at a different address, the result is
undefined.
NOTES
Trial use
RETURN VALUES
On successful completion, the msem_unlock() function returns 0 (zero). On error, the msem_unlock() function returns -1 and sets errno to
indicate the error.
ERRORS
If the msem_unlock() function fails, errno may be set to one of the following values: MSEM_IF_WAITERS was specified and there were no wait-
ers. The sem parameter points to an msemaphore structure which specifies a semaphore which has been removed, or the condition parameter is
invalid.
RELATED INFORMATION
Functions: msem_init(3), msem_lock(3), msem_remove(3) delim off
msem_unlock(3)