Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to use a Shell Script for specific commands Post 302360291 by dr.house on Thursday 8th of October 2009 01:53:13 PM
Old 10-08-2009
You could, for example, compile a list of all directories in question ...

Code:
/some/where
/some/where/else
/any/where
/any/where/else

... then let your script iterate through this list on a one by one basis:

Code:
cat folders.list | \
while read ENTRY 
do
  process $ENTRY
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run unix commands in a new shell inside a shell script?

Hi , I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a... (2 Replies)
Discussion started by: hkapil
2 Replies

2. Shell Programming and Scripting

shell script to run a few commands help!

Hi friends this is first post i am very new to shell scripting so i require your expertise to do the following thank u I need to write a shell script which will run the following commands pg_dump bank > backup(Enter) Wait for bash prompt to appear coz it indicates that the command is... (23 Replies)
Discussion started by: perk_bud
23 Replies

3. Shell Programming and Scripting

How to get ascii value using shell commands/script

Hi gurus, Need command/code to get the ASCII value for a character say 65 for A and vice versa in shell script. Thanks in advance (2 Replies)
Discussion started by: kittu1979
2 Replies

4. Red Hat

how to write shell specific commands?

I am using Fedora 8,Red hat 9. Whenever we write a new command. Then we goto "/usr/bin" and then place this in this directory.And hence we can use it as a command anywhere from the terminal. We generally see commands like "trap" which run only in bash shell.We also have other shell specific... (1 Reply)
Discussion started by: nsharath
1 Replies

5. Shell Programming and Scripting

Why can't embed commands like fg or bg in a shell script ?

Hi Can someone explain in an easy way that why can't embed commands like fg or bg in a shell script ? (4 Replies)
Discussion started by: qiulang
4 Replies

6. Shell Programming and Scripting

Using Ex editor commands in a shell script - Help!

Hi all, I am trying to use the Ex editor and its commands in a script - more specifically within an if statement within a while loop. Here are the basics of the loop: cat $file1 | while read line do grep $line $file2 if ] then echo $line > $file2 elseex $file2 /ESI185... (4 Replies)
Discussion started by: luke222010
4 Replies

7. Shell Programming and Scripting

Linux commands in shell script?

I am trying to learn to write basic shell scripts. I have a little experience with perl but none with shell. I am trying to write a simple script to write the last 15 or so lines of log files for my web server to a temp file so I can view all at once. Here's what I have. Are you not able to use... (6 Replies)
Discussion started by: ktb231
6 Replies

8. UNIX for Dummies Questions & Answers

Commands to run from shell script

Hi script> isumid 98765432 if i give above command in cmd prompt it is running the same thing if i give inside the shell script it is not working below is the code #!/bin/bash isumid 98765432 please give me a solution (16 Replies)
Discussion started by: Ramrangasamy
16 Replies

9. Shell Programming and Scripting

Script to run commands at a specific time.

Hello All, I have written a script which which is working fine to a certain logic of it. But i want a part of the script to run two commands at 00:10 hrs every day. These two command are 1. rm -rf /path/to/folder 2. mail the content of a file. How do i achieve this. Thanks. ... (4 Replies)
Discussion started by: Siddheshk
4 Replies

10. UNIX for Beginners Questions & Answers

Two exec commands in one shell script?

Hi Folks - Is there a way to add two execs to one script? For instance, I need to redirect the stdout and stderr to two separate directories. I want to do this: #::-- Direct STDOUT and STDERROR to repositories --::# exec 2>"${_ERRORFILE}" > "${_LOGFILE}" exec 2>"/new/path/file.err" >... (7 Replies)
Discussion started by: SIMMS7400
7 Replies
HSEARCH(3)						     Linux Programmer's Manual							HSEARCH(3)

NAME
hcreate, hdestroy, hsearch - hash table management SYNOPSIS
#include <search.h> int hcreate(size_t nel); ENTRY *hsearch(ENTRY item, ACTION action); void hdestroy(void); #define _GNU_SOURCE #include <search.h> int hcreate_r(size_t nel, struct hsearch_data *tab); int *hsearch_r(ENTRY item, ACTION action, ENTRY **ret, struct hsearch_data *tab); void hdestroy_r(struct hsearch_data *tab); DESCRIPTION
The three functions hcreate, hsearch, and hdestroy allow the user to create a hash table (only one at a time) which associates a key with any data. The three functions hcreate_r, hsearch_r, hdestroy_r are reentrant versions that allow the use of more than one table. First the table must be created with the function hcreate(). The argument nel is an estimate of the maximum number of entries in the ta- ble. The function hcreate() may adjust this value upward to improve the performance of the resulting hash table. The corresponding function hdestroy() frees the memory occupied by the hash table so that a new table can be constructed. The argument item is of type ENTRY, which is a typedef defined in <search.h> and includes these elements: typedef struct entry { char *key; void *data; } ENTRY; The field key points to the NUL-terminated string which is the search key. The field data points to the data associated with that key. The function hsearch() searches the hash table for an item with the same key as item (where "the same" is determined using strcmp(3)), and if successful returns a pointer to it. The argument action determines what hsearch() does after an unsuccessful search. A value of ENTER instructs it to insert a copy of item, while a value of FIND means to return NULL. RETURN VALUE
hcreate() and hcreate_r() return 0 when allocation of the memory for the hash table fails, nonzero otherwise. hsearch() returns NULL if action is ENTER and the hash table is full, or action is FIND and item cannot be found in the hash table. hsearch_r() returns 0 if action is ENTER and the hash table is full, and nonzero otherwise. ERRORS
ENOMEM Out of memory. CONFORMS TO
The functions hcreate, hsearch, and hdestroy are from SVID, and are described in POSIX 1003.1-2001. The functions hcreate_r, hsearch_r, hdestroy_r are GNU extensions. BUGS
SVID and POSIX 1003.1-2001 specify that action is significant only for unsuccessful searches, so that an ENTER should not do anything for a successful search. The libc and glibc implementations update the data for the given key in this case. Individual hash table entries can be added, but not deleted. EXAMPLE
The following program inserts 24 items in to a hash table, then prints some of them. #include <stdio.h> #include <search.h> char *data[] = { "alpha", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel", "india", "juliet", "kilo", "lima", "mike", "november", "oscar", "papa", "quebec", "romeo", "sierra", "tango", "uniform", "victor", "whisky", "x-ray", "yankee", "zulu" }; int main() { ENTRY e, *ep; int i; /* starting with small table, and letting it grow does not work */ hcreate(30); for (i = 0; i < 24; i++) { e.key = data[i]; /* data is just an integer, instead of a pointer to something */ e.data = (char *)i; ep = hsearch(e, ENTER); /* there should be no failures */ if (ep == NULL) { fprintf(stderr, "entry failed "); exit(1); } } for (i = 22; i < 26; i++) { /* print two entries from the table, and show that two are not in the table */ e.key = data[i]; ep = hsearch(e, FIND); printf("%9.9s -> %9.9s:%d ", e.key, ep ? ep->key : "NULL", ep ? (int)(ep->data) : 0); } return 0; } SEE ALSO
bsearch(3), lsearch(3), tsearch(3), malloc(3) GNU
2001-12-26 HSEARCH(3)
All times are GMT -4. The time now is 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy