checking invoice number not correct


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting checking invoice number not correct
# 8  
Old 03-29-2007
Quote:
Originally Posted by matrixmadhan
Code:
input:
01185
01191
01192
01193
01196
01197

the input you gave is of the above form
is the input still the same ?
if so,

how is it possible to categorize as CLIENT, CLIENTB, CLIENTC ?
Is there any logic based on the numbers ? Smilie
To me its still not clear!

Again your sample input and expected output would be of great help!
sorry for the confuse...
my script using below to get the invoice number. So I will add a few ls line to show different group....

ls -1 /appl/appl/archive/client/CACHE/CLIENTINVOICE*[0-9].archived | sort | cut -c 48,49,50,51
# 9  
Old 03-29-2007
I am not sure if I understood your problem correctly...

If file conatins the result of ls..

cat file
/appl/appl/archive/client/CACHE/CLIENTINVOICE05021.archived
/appl/appl/archive/client/CACHE/CLIENTINVOICE05025.archived
/appl/appl/archive/client/CACHE/CLIENTBINVOICE40023.archived
/appl/appl/archive/client/CACHE/CLIENTCINVOICE10000.archived
/appl/appl/archive/client/CACHE/CLIENTBINVOICE40029.archived
/appl/appl/archive/client/CACHE/CLIENTCINVOICE10005.archived
/appl/appl/archive/client/CACHE/CLIENTCINVOICE10006.archived
/appl/appl/archive/client/CACHE/CLIENTCINVOICE10007.archived


Code:
sed 's/\(.*\)\([0-9]\{5\}\)\(.*\)/\1 \2/' file | sort | awk -F" " '{ if (NR==1){ dat=$2; str=$1; } else {  if ($1==str)  { while(++dat<$2) printf "%s %05d Are not in seq \n",str,dat;  } else {str=$1;dat=$2;}  }       }'


Output will be

/appl/appl/archive/client/CACHE/CLIENTBINVOICE 40024 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTBINVOICE 40025 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTBINVOICE 40026 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTBINVOICE 40027 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTBINVOICE 40028 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTCINVOICE 10001 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTCINVOICE 10002 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTCINVOICE 10003 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTCINVOICE 10004 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTINVOICE 05022 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTINVOICE 05023 Are not in seq
/appl/appl/archive/client/CACHE/CLIENTINVOICE 05024 Are not in seq


Is this what you are looking for?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Getting correct port number from process id

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)
Discussion started by: sravani25
3 Replies

2. Shell Programming and Scripting

Checking number of commas in each line.

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)
Discussion started by: Anupam_Halder
4 Replies

3. Shell Programming and Scripting

checking a number

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)
Discussion started by: gangsta
8 Replies

4. Homework & Coursework Questions

checking for number of arguments.

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)
Discussion started by: brooksie91
1 Replies

5. UNIX for Dummies Questions & Answers

Basic number checking problem

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)
Discussion started by: ChrisHoogie
8 Replies

6. UNIX for Dummies Questions & Answers

checking if parameter passed is a number

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)
Discussion started by: magnia
2 Replies

7. Programming

Problem in getting the correct number from the string.

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)
Discussion started by: SamRoj
2 Replies

8. Shell Programming and Scripting

Checking for proper number of files in dir

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)
Discussion started by: crowman
2 Replies

9. Shell Programming and Scripting

checking the smallest and largest number

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)
Discussion started by: subin_bala
4 Replies

10. UNIX for Dummies Questions & Answers

sequence number checking

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)
Discussion started by: nhatch
1 Replies
Login or Register to Ask a Question