Hello,
Decided to edit the whole post as nobody was replying, and it was pretty darn big as it was. So I have to write this script for my assignment, and I am new to scripting. The problem is we have to handle command line args, process an operations file which adds supermarket items to a database file (by database I don't mean sql, it's simply a regular file), and send standard output. So far I have dealt with the cmdline args. But I am stuck on how I go about processing the file.
basically the input looks like this.
This will be converted to uppercase as I have already done using tr.
then I need to use grep or something to check the first word delimited by ':' or newline, eg. displayall is one command that can be used to show the whole database, add to add the rest of the line to database, delete to delete a line. etc
I'm not sure how to go about this, I'm guessing I could use a for loop to read each line and process line by line something like:
so naturally I would have functions for add, delete, displayall, findproduct, findbrand.
Q1. what's the best way to go about this?
Q2. is it possible to call functions from other files, or should I separate my functions by creating separate scripts and just call on those scripts?
Reason I ask #2 is having a big wall of code makes debugging hard, for someone new to scripting like me.
Thanks.
---------- Post updated 11-25-09 at 12:07 PM ---------- Previous update was 11-24-09 at 10:12 PM ----------
Thought maybe:
or something... would this work?
in that grep matches ADD, in current line and sends output to tempvar.
then case in tempvar is add, so then we grep the line again inverting match the rest of line being BREAD - WHITE:TIPTOP:4 and pipe to add function
Hi guys ,
if a=12345678 i need to check that "a"
less than 8 char
greater than 8 char
equal to 8 char
contain only numeric.
I done the above with seperate if condition to check and print the proper echo statement according to the result.i.e more than 8 char/lessthan etc..
can i able... (2 Replies)
Hi All,
I am working on a file transfer tool between unix servers.
for this i am looking for a small database which is free and compatible with all unix OS and can be bundled in a package with other scripts.
Any suggestions (8 Replies)
we are getting files on daily basis.we need to process these files.
i need a unix shell script where we can count
1-The no of files processed
2-No of data/record processed for each files.
The script should log these details into a database table. If there is any error while file... (3 Replies)
Discussion started by: Atul kumar
3 Replies
LEARN ABOUT PHP
zgrep
ZGREP(1) General Commands Manual ZGREP(1)NAME
zgrep - search possibly compressed files for a regular expression
SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename...
DESCRIPTION
Zgrep invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code:
(-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, then the
standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep.
If the GREP environment variable is set, zgrep uses it as the grep program to be invoked.
EXIT CODE
2 - An option that is not supported was specified.
AUTHOR
Charles Levert (charles@comm.polymtl.ca)
SEE ALSO grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1)ZGREP(1)