Sponsored Content
Full Discussion: BASH, HASH and AWK
Top Forums UNIX for Dummies Questions & Answers BASH, HASH and AWK Post 302287191 by Devyn on Friday 13th of February 2009 01:54:09 AM
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,
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk Hash Function.

I have a file with a format of A,2 B,2 G,3 A,2 A,3 A,2 D,7 A,2 E,2 A,2 I need to create a sum of each alphabet with the numbers assigned to it using awk. (2 Replies)
Discussion started by: dinjo_jo
2 Replies

2. Shell Programming and Scripting

Print Entire hash list (hash of hashes)

I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes). Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash. Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies

3. Shell Programming and Scripting

Assigning a hash to another hash key

Hello, I have a hash in hsh. I need to assign it to another hash globalHsh. I think the below statement does not work $globalHsh{$id} = %hsh; What is the right way to assign it? Thanks (3 Replies)
Discussion started by: rsanjay
3 Replies

4. Shell Programming and Scripting

Perl Hash:Can not keep hash data in the same order that it was inserted

Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below. #!/usr/bin/perl use warnings; use Tie::IxHash; use strict; tie (my %programs, "Tie::IxHash"); while (my $line = <DATA>) { chomp $line; my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies

5. Shell Programming and Scripting

perl hash - using a range as a hash key.

Hi, In Perl, is it possible to use a range of numbers with '..' as a key in a hash? Something in like: %hash = ( '768..1536' => '1G', '1537..2560' => '2G' ); That is, the range operation is evaluated, and all members of the range are... (3 Replies)
Discussion started by: dsw
3 Replies

6. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies

7. Shell Programming and Scripting

Dynamically parse BibTeX and create hash of hash

Hello gurus, Iam trying to parse following BibTex file (bibliography.bib): @book{Lee2000a, abstract = {Abstract goes here}, author = {Lee, Wenke and Stolfo, Salvatore J}, title = {{Data mining approaches for intrusion detection}}, year = {2000} } @article{Forrest1996, abstract =... (0 Replies)
Discussion started by: wakatana
0 Replies

8. UNIX for Dummies Questions & Answers

Help in awk/bash

Hi, I am also a newbie in awk and trying to find solution of my problem. I have one reference file 1.txt with 2 columns and I want to search other 10 files (a.txt, b.txt......h.txt each with 5 columns) corresponding to the values of 2nd column from 1.txt. If the value from 2nd column from 1.txt... (0 Replies)
Discussion started by: bioinfo
0 Replies

9. Shell Programming and Scripting

awk command hash array not printing

I'm new to awk command. The HASH ARRAY is not printing. Merging 2 files togather. vault_input.txt 3P04_Dep_Inxml:2230 REM02_Dep_Inxml:2200 REM03_Dep_Inxml:2400 REM05:2200 REM06:2200 tst6.txt Nov:10:2115:3P04_Dep_Inxml Nov:10:2129:REM02_Dep_Inxml Nov:10:2235:REM03_Dep_Inxml... (5 Replies)
Discussion started by: Sanj123
5 Replies

10. Shell Programming and Scripting

Need to print hash of hash in table format

Hi, I have a hash of hash where it has name, activities and count i have data like this - $result->{$name}->{$activities} = $value; content of that are - name - robert tom cat peter activities - running, eating, sleeping , drinking, work i need to print output as below ... (3 Replies)
Discussion started by: asak
3 Replies
Hash(3pm)						User Contributed Perl Documentation						 Hash(3pm)

NAME
Test::Data::Hash -- test functions for hash variables SYNOPSIS
use Test::Data qw(Hash); DESCRIPTION
This modules provides a collection of test utilities for hash variables. Load the module through Test::Data. Functions exists_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH exists. The function does not create KEY in HASH. not_exists_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH does not exist. The function does not create KEY in HASH. hash_value_defined_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is defined. The function does not create KEY in HASH. hash_value_undef_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is undefined. The function does not create KEY in HASH. hash_value_true_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is true. The function does not create KEY in HASH. hash_value_false_ok( KEY, HASH [, NAME] ) Ok if the value for KEY in HASH is false. The function does not create KEY in HASH. SEE ALSO
Test::Data, Test::Data::Array, Test::Data::Function, Test::Data::Scalar, Test::Builder SOURCE AVAILABILITY
This source is in Github: http://github.com/briandfoy/test-data/tree/master AUTHOR
brian d foy, "<bdfoy@cpan.org>" COPYRIGHT AND LICENSE
Copyright (c) 2002-2009 brian d foy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2009-02-12 Hash(3pm)
All times are GMT -4. The time now is 12:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy