I need to write a script which analyses an invoice file, counting the amount of pages in the file to be printed per account number and per invoice. The account numbers are stored in another file which has instructions on what do with ach customers invoice as per their account number.
You will need to post a lot more information than that for anyone to be able to help you.
What OS are you using?
What shell are you using?
What does the data look like?
What programming language have you selected?
What have you coded thus far?
What specifically can you not figure out?
1) I think its Solaris.
2) Unix
3) The data in the invoice file is in free form and the data in the other file is in comma delimted format
4) unix shell scripting
5) I don't know much about Unix and all I have managed to do thus far is to write a script which unzips the free form file to a temp folder.
6) how to analyse the file so i can give a page count per account number
What OS are you using?
Run the command and post results: uname -a
What shell are you using? Unix is not a shell.
Run the command and post results: echo $SHELL
What does the data look like? - Your answer isn't much to go on - unless you post an example of the data, you may be on your own for this. You won't be able to write a script if you don't know what the data looks like to grab the information you need. We can't help since we don't have any clue on what the data looks like.
What programming language have you selected?
sh, ksh, csh, bash, tcsh, .... are examples of shells. Each can be used to write a shell script.
What specifically can you not figure out? 6) how to analyse the file so i can give a page count per account number.
We can't assist without knowing the layout of the file - if you can't post the format or part of the file (as it may be something you can't share with outsiders), then you need to look at it and figure it out.
How do you do this processes today (if at all)? Normally if you can look at how the process is done manually, you can code something to do it automatically.
I'm writing it in .sh
I cannot give samples of the file. But let me try to explain it roughly. If you receive your phone bill invoice/statement in the post it could be one - ten pages long showing the invoice total for example, what calls you made etc. This invoice file contains statements in free form (like in notepad) in no specific format and gets printed from there. Each invoice has a certain number of pages, so somewhere in the file it will say Page: 1 or 2 or whatever depending on the Account Number:. The other file is a comma delmited file giving details of each customer, like name, address and whether the invoice gets posted or emailed.
I need to pick up the account number from this txt file, pick up whether it gets posted or emailed and then in the invoice file count the number of pages that gets printed and posted and emailed per customer.
I know this is all confusing but basically I need to get information from a file where the data is not in a specific column or line. There is currently no manual process in place.
Seems like you need to go through your second file (comma delimited file) and get the account information. Using the account number, you can then go through your invoice file. It still isn't clear to me if you are looking to grab all the pages of information for a specific account or not.
Once you have the account number, you could search through the invoice data and pull the information you need - one way would be the awk command - searching for a specific begining string and ending string. Your begining string would be the account number in the invoice file - the ending string I would not know since you can't post a sample. See the man page on awk - look for /start/, /stop/ which prints all lines between the start/stop pair. Then once you have all the pages, you do what you need to and go on to the next account number.