Unix/Linux Go Back    


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

BASH, HASH and AWK

UNIX for Dummies Questions & Answers


Tags
awk, bash, find, grep, hash

 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 12-09-2008   -   Original Discussion by Corpsehy
Corpsehy's Unix or Linux Image
Corpsehy Corpsehy is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 29 December 2008, 3:02 PM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Attached Thumbnails
BASH, HASH and AWK-hwscript-png  
Sponsored Links
    #2  
Old Unix and Linux 12-10-2008   -   Original Discussion by Corpsehy
Corpsehy's Unix or Linux Image
Corpsehy Corpsehy is offline
Registered User
 
Join Date: Dec 2008
Last Activity: 29 December 2008, 3:02 PM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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? :-)
Sponsored Links
    #3  
Old Unix and Linux 02-13-2009   -   Original Discussion by Corpsehy
Devyn's Unix or Linux Image
Devyn Devyn is offline
Registered User
 
Join Date: Feb 2005
Last Activity: 10 April 2016, 2:10 PM EDT
Posts: 71
Thanks: 10
Thanked 2 Times in 2 Posts
> 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,
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
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
Print Entire hash list (hash of hashes) Alalush Shell Programming and Scripting 1 08-06-2008 09:40 AM
MD5 hash calculation zedex Programming 4 02-24-2007 02:37 AM



All times are GMT -4. The time now is 01:46 PM.