Sponsored Content
Top Forums Shell Programming and Scripting How to store info from a txt file into a hash? Post 302997839 by Eric1 on Saturday 20th of May 2017 04:14:19 PM
Old 05-20-2017
Don't worry, the info I posted aren't real people. I'll try out your code in a bit Aia, thank you for the examples. Is there no way for me to accomplish this task of mine with the open commend though? As in something like-

open($patient_names, "+<Patient_Names.txt");
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

When a file is created where does unix store the info?

When a file is created where does unix store the information about the file? (5 Replies)
Discussion started by: goodmis
5 Replies

2. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies

3. Shell Programming and Scripting

Open txt and store line in a var

Hi I realy need to find a way to do a script that does the following: search a word in a txt file then store on a var the letters that are on the right like this is an exemple, I want to store from here ...abcdefg... so I need a var that receive ...abcdefg... Is that possible?... (8 Replies)
Discussion started by: ruben.rodrigues
8 Replies

4. UNIX for Advanced & Expert Users

Perl loop txt and check if a hash key

Hi, The task i have to do is to 1- create a database contains the Names .run the query and store results in hash make the Name field is the hash key 2- in the same time i have a txt which i will loop through it word by word and check for each word if a hash key ( compare it with the Names in... (0 Replies)
Discussion started by: eng_shimaa
0 Replies

5. Shell Programming and Scripting

Generate a mail when you add info to a txt file

Hi, I have an application's log file: /var/log/logfile which is feeded from time to time due to an application. This file contains data, what I want is: -Whenever some new data is copied to /var/log/logfileI want to generate an email to root BUT only with the new added data in the body.... (6 Replies)
Discussion started by: iga3725
6 Replies

6. Shell Programming and Scripting

How to store the sql query output into txt file?

Hi I want ot save SQL query result in one txt file. for that i have written one code line sqlplus -s $dbstring @/usr/local/bin/sched/nightly_Cronjob/exec_123.sql >> /usr/local/bin/sched/nightly_Cronjob/result.txt but it is not working . database : Oracle so please advice me how can i... (7 Replies)
Discussion started by: Himanshu_soni
7 Replies

7. Programming

store information in hash and display number of keys.

I am trying to store this information (info and number) in hash. number is the key and info is value in a hash.i shown my code below. #!/usr/bin/perl use warnings; use strict; use XML::LibXML::Reader; my $file;open $file, 'formal.xml'); my $reader =... (0 Replies)
Discussion started by: veerubiji
0 Replies

8. Shell Programming and Scripting

Store output of DB Cursor to a txt file

I am writing a cursor to select values from 3 tables. I want to store these values in a txt file which I will be sending via ftp. I am able to store the results of simple select queries to the txt file. but I am not sure how to store the values when using a cursor. I have given the sql query below.... (1 Reply)
Discussion started by: naveensraj
1 Replies

9. Shell Programming and Scripting

Store a column from an excel sheet (exported to txt) into a variable

I typically pull a bunch of data via SQL that lists a bunch of users and the server on which they want to access, as well as other attributes, in one row of an excel sheet and the number of rows is directly proportionate to the number of users. I'm trying to write a loop to read each line of the... (2 Replies)
Discussion started by: MaindotC
2 Replies

10. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies
HASHSTASH(3)						 libbash hashstash Library Manual					      HASHSTASH(3)

NAME
hashstash -- libbash library that implements hash data structure SYNOPSIS
hashSet <Value> <Key> <HashName> [SubHashName [...]] $retval hashGet <Key> <HashName> [SubHashName [...]] $retval hashKeys <HashName> [SubHashName [...]] hashRemove <Key> <HashName> [SubHashName [...]] hashDelete <HashName> [SubHashName [...]] DESCRIPTION
General hashstash is a collection of functions that implement basic hash data-structure in bash scripting language. The function list: hashSet Adds a value to the hash hashGet Returns a value from the hash hashKeys Returns a list of keys of the hash hashRemove Removes a key from the hash hashDelete Deletes a hash Detailed interface description follows. FUNCTIONS DESCRIPTIONS
hashSet <Value> <Key> <Hashname> [SubHashName [...]] Adds a value to the hash. Parameters: <Value> The value to set in HashName[Key]. <Key> The key for the value Value. <HashName> [SubHashName [...]] A string that contains the name of the hash. If the hash is a sub hash of another hash, the "father hash" name MUST BE WRITTEN FIRST, followed by the sub-hash name. Value will be the value of the key Key in the hash HashName. For example if you have (or want to define) hash C, which is subhash of hash B, which is subhash of hash A, and C has a key named ckey1 with value cval1, then you should use: hashSet cval1 ckey1 A B C $retval hashGet <Key> <HashName> [SubHashName [...]] Returns the value of Key in HashName to the $retval variable. Parameters: <Key> The key that hold the value we wish to get. <HashName> [SubHashName [...]] A string that contains the name of the hash. If the hash is a sub hash of another hash, the "father hash" name MUST BE WRITTEN FIRST, followed by the sub-hash name. Return Value: The value of the key Key in the hash HashName. The value is returned in the variable $retval. $retval hashKeys <HashName> [SubHashName [...]] Returns a list of keys of the hash HashName in the variable $retval. Parameters: <HashName> [SubHashName [...]] A string that contains the name of the hash. If the hash is a sub hash of another hash, the "father hash" name MUST BE WRITTEN FIRST, followed by the sub-hash name. Return Value: The value of the key Key in the hash HashName. The value is returned in the variable $retval. hashRemove <Key> <HashName> [SubHashName [...]] Removes the key Key from the hash HashName. <Key> The key we wish to remove from HashName. <HashName> [SubHashName [...]] A string that contains the name of the hash. If the hash is a sub hash of another hash, the "father hash" name MUST BE WRITTEN FIRST, followed by the sub-hash name. This function should also be used to remove a sub-hash from its "father hash". In that case, the key will be the name of the sub-hash. hashDelete <HashName> [SubHashName [...]] Deletes the hash HashName [SubHashName [...]]. Parameters: <HashName> [SubHashName [...]] A string that contains the name of the hash. If the hash is a sub hash of another hash, the "father hash" name MUST BE WRITTEN FIRST, followed by the sub-hash name. If this function is used on a sub-hash, a key with the name of the sub-hash will remain in its "father hash" and will hold a NULL value. BUGS
A hash name can only contain characters that are valid as part of bash variable names (i.e. a-zA-Z0-9_). The same applies for hash keys. As for now, there is no way of knowing if a key represents a value or a sub-hash. If a sub-hash will be used as a key, the returned value will be its keys list. EXAMPLES
Define hash table hashA with key Akey1 with value Aval1 use: % hashSet Aval1 Akey1 Ahash Now: % hashGet Akey1 Ahash % echo $retval Aval1 % hashKeys Ahash % echo $retval Akey1 % HISTORY
The idea to write hashstash library appeared when we've discovered the full power of the bash eval function. As of the name hashstash, it has two meanings. The first, it means 'stash' of hash functions. The second is, that hashstash contains sub- hashes inside, so it looks like stash of packed information. AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <gil@ran4.net> SEE ALSO
ldbash(1), libbash(1) Linux Epoch Linux
All times are GMT -4. The time now is 06:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy