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,
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Similar Threads 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 11:41 PM
awk command hash array not printing Sanj123 Shell Programming and Scripting 5 11-12-2015 01:50 AM
Help in awk/bash bioinfo Shell Programming and Scripting 33 01-10-2013 02:08 PM
Help in awk/bash bioinfo Shell Programming and Scripting 11 01-06-2013 12:33 AM
Help in awk/bash bioinfo UNIX for Dummies Questions & Answers 0 12-28-2012 07:09 PM
Dynamically parse BibTeX and create hash of hash wakatana Shell Programming and Scripting 0 12-07-2012 09: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 05:25 PM
perl hash - using a range as a hash key. dsw Shell Programming and Scripting 3 08-31-2010 08: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 12:35 PM
Assigning a hash to another hash key rsanjay Shell Programming and Scripting 3 02-21-2010 12:12 AM
scripting help with bash and awk garethsays Shell Programming and Scripting 3 05-30-2009 11:18 AM
awk bash help a-gopal Shell Programming and Scripting 2 05-08-2009 09:39 PM
BASH with AWK narasimhulu Shell Programming and Scripting 2 08-26-2008 12:59 AM
Print Entire hash list (hash of hashes) Alalush Shell Programming and Scripting 1 08-06-2008 09:40 AM
Awk Hash Function. dinjo_jo Shell Programming and Scripting 2 07-16-2008 07:30 PM
All times are GMT -4. The time now is 09:18 PM.

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





Not a Forum Member?
Forgot Password?