Unique batch and sequence creation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unique batch and sequence creation
# 1  
Old 02-03-2009
Unique batch and sequence creation

Hi Everyone,

I am working on Sun solaris. I would like to know that ,do we any way to
create unique batch in shell scripts.Basically i want to create a batch and want to create a sequence to process the records.

Regards,
gehlnar
# 2  
Old 02-03-2009
Are you talking about a unique sequence number, like databases provide?
Obviously if you have a database like Oracle you can get one by querying a sequence.
Otherwise, you will have to write a starting number to a file.
Every time you want the next sequcne, read the file, add one to the number, write the new number back to the file, then save the new number as your sequence.
Create starting number - like say 1000000
Code:
echo  "1000000"  > sequence.dat

using the sequence later - as a function that you call
Code:
sequence()
{
   if [[ -w sequence.dat ]] ; then
    a=$(<sequence.dat)
    a=$(( $a + 1 ))
    echo $a > sequence.dat
    echo $a
   else 
     echo "Error sequence not setup" > 2
     exit 1
   fi

}

#usage
newsequence=$( sequence)
# use $newsequence for something
.....................

# 3  
Old 02-04-2009
Hi Jim,

Thanks for the idea given by you. I was looking for something like this. actually we do not have any particular database on from which i can generate sequence.

Let me see how i can make use of it.

Cheers,
gehlnar
# 4  
Old 02-04-2009
Quote:
Originally Posted by jim mcnamara
Code:
sequence()
{
   if [[ -w sequence.dat ]] ; then
    a=$(<sequence.dat)


A read command will be much faster than command substitution in all shells except ksh93:

Code:
read a < sequence.dat

Quote:
Code:
   a=$(( $a + 1 ))
    echo $a > sequence.dat
    echo $a
   else 
     echo "Error sequence not setup" > 2
     exit 1
   fi

}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count occurrence of column one unique value having unique second column value

Hello Team, I need your help on the following: My input file a.txt is as below: 3330690|373846|108471 3330690|373846|108471 0640829|459725|100001 0640829|459725|100001 3330690|373847|108471 Here row 1 and row 2 of column 1 are identical but corresponding column 2 value are... (4 Replies)
Discussion started by: angshuman
4 Replies

2. Red Hat

Rm -rf * sequence

If I run rm -rf * command under one parent directory. /data > rm -rf * Is there anyway to know which files will be deleted first ? Start using code tags please, ty. (2 Replies)
Discussion started by: sameermohite
2 Replies

3. UNIX for Dummies Questions & Answers

Print unique lines without sort or unique

I would like to print unique lines without sort or unique. Unfortunately the server I am working on does not have sort or unique. I have not been able to contact the administrator of the server to ask him to add it for several weeks. (7 Replies)
Discussion started by: cokedude
7 Replies

4. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

5. Shell Programming and Scripting

Change unique file names into new unique filenames

I have 84 files with the following names splitseqs.1, spliseqs.2 etc. and I want to change the .number to a unique filename. E.g. change splitseqs.1 into splitseqs.7114_1#24 and change spliseqs.2 into splitseqs.7067_2#4 So all the current file names are unique, so are the new file names.... (1 Reply)
Discussion started by: avonm
1 Replies

6. Shell Programming and Scripting

Executing a batch of files within a shell script with option to refire the individual files in batch

Hello everyone. I am new to shell scripting and i am required to create a shell script, the purpose of which i will explain below. I am on a solaris server btw. Before delving into the requirements, i will give youse an overview of what is currently in place and its purpose. ... (2 Replies)
Discussion started by: goddevil
2 Replies

7. Shell Programming and Scripting

Managing sequence to make unique record

Hi Everyone, Using shell script i am getting final file as attached below. In this 4th column value should be unique using any sequence. for instance I've 1_13020_SSGM which is appearing 6 times in file and i should change it like 1_13020_SSGM_1,1_13020_SSGM_2,....1_13020_SSGM_6. Can someone... (4 Replies)
Discussion started by: gehlnar
4 Replies

8. Shell Programming and Scripting

get part of file with unique & non-unique string

I have an archive file that holds a batch of statements. I would like to be able to extract a certain statement based on the unique customer # (ie. 123456). The end for each statement is noted by "ENDSTM". I can find the line number for the beginning of the statement section with sed. ... (5 Replies)
Discussion started by: andrewsc
5 Replies

9. Shell Programming and Scripting

To grep in sequence

Hi, I have a log file containg records in sequence <CRMSUB:MSIN=2200380,BSNBC=TELEPHON-7553&TS21-7716553&TS22-7716553,NDC=70,MSCAT=ORDINSUB,SUBRES=ONAOFPLM,ACCSUB=BSS,NUMTYP=SINGLE; <ENTROPRSERV:MSIN=226380,OPRSERV=OCSI-PPSMOC-ACT-DACT&TCSI-PPSMTC-ACT-DACT&UCSI-USSD;... (17 Replies)
Discussion started by: helplineinc
17 Replies

10. Shell Programming and Scripting

help to execute programs in sequence through batch

I need help to create batch file . I want to run some programs in sequence in batch mode . I have one file which contains the name of program and command The test.bat file contain this data stsrun -v devel area1.exp stsrun -v devel prime1.exp stsrun -v devel treat.exp Please help... (1 Reply)
Discussion started by: getdpg
1 Replies
Login or Register to Ask a Question