I have the following script to check the invoice number is in order or not.
However, it cannot show out the correct information. My expect output show below and I would like to only list out the NOT IN SEQUENCE inovice number (not included "ok")
#!/bin/sh
start=1
for file_number in `ls -1 /appl/appl/archive/client/CACHE/CLIENTINVOICE*[0-9].archived | sort | cut -c 48,49,50,51`
do
if [ $start -eq 1 ] ; then
# this is the first pass of the loop, so we've got nothing to compare
start=0
previous=$file_number
else
# this is not the first pass of the loop
previous=`expr $previous + 1`
echo "comparing $file_number and $previous ... "
if [ $file_number = $previous ] ; then
echo "OK"
else
seqno=`expr $file_number - 1`
echo "CLIENTINVOICE$invoiceno are not in sequence "
fi
fi
previous=$file_number
done
input:
01185
01191
01192
01193
01196
01197
.
.
.
script output:
01190 are not in seq
01195 are not in seq
expect output
01186 are not in seq
01187 are not in seq
01188 are not in seq
01189 are not in seq
01190 are not in seq
01194 are not in seq
01195 are not in seq
01186 Are not in seq
01187 Are not in seq
01188 Are not in seq
01189 Are not in seq
01190 Are not in seq
01194 Are not in seq
01195 Are not in seq
Great, it work...but I problem..due to the directory have a lot of different group of invoice such as
CLIENTINVOICE*[0-9].archived
CLIENTBINVOICE*[0-9].archived
CLIENTCINVOICE*[0-9].archived
Can I output the result which the group name as well..? so that i can do summary for each group of missing.
expected:
CLIENTINVOICE01187 Are not in seq
CLIENTINVOICE01188 Are not in seq
CLIENTINVOICE01189 Are not in seq
CLIENTINVOICE01190 Are not in seq
CLIENTINVOICE01194 Are not in seq
CLIENTBINVOICE02201 Are not in seq
CLIENTBINVOICE02203 Are not in seq
CLIENTCINVOICE02203 Are not in seq
CLIENTCINVOICE02207 Are not in seq
CLIENTCINVOICE02212 Are not in seq
I just want to have more output detail. your output:
Output:
01186 Are not in seq
01187 Are not in seq
01188 Are not in seq
01189 Are not in seq
01190 Are not in seq
01194 Are not in seq
01195 Are not in seq
my expected output (due to the file with a lot of client group in it)
group type:
CLIENTINVOICE*[0-9].archived
CLIENTBINVOICE*[0-9].archived
CLIENTCINVOICE*[0-9].archived
output:
CLIENTINVOICE01187 Are not in seq
CLIENTINVOICE01188 Are not in seq
CLIENTINVOICE01189 Are not in seq
CLIENTINVOICE01190 Are not in seq
CLIENTINVOICE01194 Are not in seq
CLIENTBINVOICE02201 Are not in seq
CLIENTBINVOICE02203 Are not in seq
CLIENTCINVOICE02203 Are not in seq
CLIENTCINVOICE02207 Are not in seq
CLIENTCINVOICE02212 Are not in seq
Hi All,
i am trying to find the Jobss port number(either default port number or any other port number assigned) from the running process id.
But it's giving me multiple port numbers when searching with netstat command. Can someone help me in finding the correct port number from the... (3 Replies)
Hi All,
I am checking whether each line is having "n" number of commas or nor. In case not then I need to exit the process.
I tried
cat "$TEMP_FILE" | while read LINE
do
processing_line=`expr $processing_line + 1`
no_of_delimiters=`echo "$LINE" | awk -F ',' '{ print NF }'`
if
... (4 Replies)
ok im trying to find out how many cars a user enters. Its giving me an error message of "integer expression expected"
Basically if i enter any number over 0 (zero) it should continue
read -p "How many cars:" carsn
test $cars -ge 1
test $? -ne 0 && read -p "Invalid number.... (8 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Your script must check for the correct number of arguments (one argument). If somebody tries to invoke the... (1 Reply)
Hello all
I am having problems using a bash script to read the input from the user and checking that its a valid number. I only want the user to input a maximum of a 3 number string (321 , 521 , 871 etc.). Anything longer or that includes a chararcter or symbol will display an error message.
... (8 Replies)
I have written a function that fills an array and another function where if a parameter is supplied it will jump to that part of the array and cat it to the screen.
I need to put in some checks to make sure the parameter supplied is firstly a number and then not a number great than the length of... (2 Replies)
I have string named texts which consist of section label “BOOK-SEC-“. Section starts from 1 to n, where n is a number. For this example conside the value of n is 9. That is, the string variable looks like
“BOOK-SEC-1... (2 Replies)
Using Solaris 10 and sh.
I have three files.
mydirs.txt
/dir1/dir2/dir3
/dir4/dir5/dir6
mydirshave.txt
1
2
mydirsshouldhave.txt
2
2
For each directory listed in mydirs.txt I should have the number of files equal to mydirshouldhave.txt. But using -ls |wc -l- on the dirs I get what... (2 Replies)
Hi All,
My script is reading a log file line by line
log file is like ;
19:40:22 :INFO Total time taken to Service External Request---115ms
19:40:25 DEBUG : Batch processed libdaemon.x86_64 0-0.10-5.el5 - u
19:40:22 INFO Total time taken to Service External Request---20ms
19:40:24... (4 Replies)
Hi there,
I'm wanting to produce a shell script that will check through some file names and identify a skip in sequence (four digit seq num in file name).
I have played on the idea of havng a file that has a sorted list of file names which I can read line at a time and cut out the sequence... (1 Reply)