Home Man
Search
Today's Posts
Register

This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in the UNIX for Beginners Questions & Answers forum.

BASH, HASH and AWK

Tags
awk, bash, beginners, find, grep, hash

 

 
Thread Tools Search this Thread
# 1  
Old 12-09-2008
BASH, HASH and AWK

Hi,

I am working on this idea that I want to process some information from a command dump.

Using the dump I will search for a string. If it finds the string, it must post a
different/associated string to output/logfile.
Example:
'Find "cookie jar"' then 'echo "carpool/tomorrow" > logfile'

It does not stop with 1 string to search for, it will have around 100 different
strings to search for, and everyone have some other content assigned to it, thus it
should be some clever loop.
I COULD have written one grep for each value, but since it is growing by the day,
I find that a waste of lines and bytes.

To prevent an infinite loop, it should remove what it has already found from the
sourcelist of what to search for or somehow mark it as processed.
(The sourcelist is overwritten each time the PC boots with an updated one)

The tricky bit for me is both how I can arrange it with a HASH table, I've done
something similar in PERL, but in BASH/AWK I am unable to do this. The system is very
limited and its not permitted toexpand on its available apps by any byte atm.

I've drawn out how I think the design is going to work.

In itself, there are several commands it will search the output for, but I am used to
having a launch script, that then uses a "core search" script with the variables that
designs it to that and that output file, predefined variables file and logfile.
It gives control and scalabillity ;-)

(The pink area is where the core script loops in itself to search for every available word)

Is this hard to acomplish?
I've written some BASH scripts in the past, aswell as some BATCH and PERL scripts,
though nothing close to this complexity.
BASH, HASH and AWK-hwscript-png  

# 2  
Old 12-10-2008
What I really need help with, is a script that searches for a changable string, if it finds it, we replace the output with the corresponding value/string.

say if I have a datafile with this info(string to search for separated by a , with the output after it):

Code:
data searchable string, this is for the output to be posted
another searchable string, this is yet again for the output to be posted.
third wonder searchable, this is another output string

It would without a hitch with either ; or = or any other sign to separate the two, just so if the first is found, the second is posted.

Any ideas? :-)
# 3  
Old 02-13-2009
> The tricky bit for me is both how I can arrange it with a HASH table, I've done
> something similar in PERL, but in BASH/AWK I am unable to do this.

Might not be exactly what you're looking for but...

With regards to above, you could try this: Creating associative or hash arrays in bash using sed and strings without the use of arrays, looping and conditionals.
You'll have to tweak that code for your tastes though to use different delimeters depending on what's appropriate to you.

Regards,
 

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need to print hash of hash in table format asak Shell Programming and Scripting 3 11-18-2016 10:41 PM
Dynamically parse BibTeX and create hash of hash wakatana Shell Programming and Scripting 0 12-07-2012 08:51 AM
Compare values of hashes of hash for n number of hash in perl without sorting. asak Shell Programming and Scripting 1 10-10-2012 04:25 PM
perl hash - using a range as a hash key. dsw Shell Programming and Scripting 3 08-31-2010 07:03 AM
Perl Hash:Can not keep hash data in the same order that it was inserted jgfcoimbra Shell Programming and Scripting 1 03-23-2010 11:35 AM
Assigning a hash to another hash key rsanjay Shell Programming and Scripting 3 02-20-2010 11:12 PM
perl hash pritish.sas Shell Programming and Scripting 3 07-20-2009 05:53 AM
Print Entire hash list (hash of hashes) Alalush Shell Programming and Scripting 1 08-06-2008 08:40 AM
Perl Hash Harikrishna Shell Programming and Scripting 1 06-04-2008 07:03 AM
Hash within array, within hash, within array... jsmoriss Shell Programming and Scripting 1 07-10-2006 09:26 PM


All times are GMT -4. The time now is 05:32 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password