Sponsored Content
Homework and Emergencies Homework & Coursework Questions Alternative solution to nested loops in shell programming Post 302955805 by Sandeep Pattnai on Monday 21st of September 2015 07:35:51 PM
Old 09-21-2015
Hi Corona688/Rudi C,

As per your suggestion, I have changed the tr -d with the "sed" to remove spaces. But still I am seeing the same performance. Could you please suggest some alternate solution to this problem?

Thanks
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grepping within nested for loops

Good morning - I have publication lists from 34 different faculty members. I need to end up with the numbers of publications in common across all 34 faculty. I need to grep person1 (last name) in list2, person1 in list3, person1 in list 4, etc., then person2 in list3, person 2 in list4, etc.,... (2 Replies)
Discussion started by: Peggy White
2 Replies

2. Shell Programming and Scripting

nested for loops

I need help getting over this bump on how nested for loops work in shell. Say i was comparing files in a directory in any other language my for loop would look like so for(int i=0;to then end; i++) for(int y = i+1; to the end; y++) I can't seem to understand how i can translate that... (5 Replies)
Discussion started by: taiL
5 Replies

3. Shell Programming and Scripting

Korn Shell programming (FTP, LOOPS, GREP)

Hello All, I have another Korn shell question. I am writing a script that will ftp a file from my production database to my test database. To this, I have to construct a loop that checks a specified folder for a file. If the file exists, I want it execute the ftp protocol and then exit. ... (2 Replies)
Discussion started by: jonesdk5
2 Replies

4. Shell Programming and Scripting

Nested while loops (ksh scripting)

You can use one while inside another? I made the following script (without really knowing if I can use two while) to get 3 numbers different from each other at random: num1=$(( $RANDOM % 10 )) num2=$num1 while do num2=$(( $RANDOM % 10 )) done num3=$num1 while do while do... (1 Reply)
Discussion started by: ale.dle
1 Replies

5. Shell Programming and Scripting

KSH nested loops?

KSH isn't my strong suit but it's what my company has to offer. I've got a script with two nested loops, a FOR and UNTIL, and that works fine. When I add a CASE into the mix I end up getting "Unexpected 'done' at line xx" errors. Any suggestions on this? for divi in at ce ci cm co de di fl... (9 Replies)
Discussion started by: mrice
9 Replies

6. UNIX for Dummies Questions & Answers

Faster than nested while read loops?

Hi experts, I just want to know if there is a better solution to my nested while read loops below: while read line; do while read line2; do while read line3; do echo "$line $line2 $line3" done < file3.txt done < file2.txt done < file1.txt >... (4 Replies)
Discussion started by: chstr_14
4 Replies

7. Shell Programming and Scripting

Nested for loops

Greetings All, The following script attempts to enumerate all users in all groups in the group file(GROUP) and echo the following information: GROUP ---> USER The script is as follows: IFS="," for GROUP in `ypcat -k group | cut -d" " -f1` do for USER in `ypcat -k group... (13 Replies)
Discussion started by: jacksolm
13 Replies

8. UNIX for Dummies Questions & Answers

Executing nested loops+foreach

It's been a while since I used csh formatting and I am having a little bit of trouble with a few things. Things seem so much easier to execute in Matlab, however I need to do this on the terminal because of the programs I am trying to interact with. So here's what I want to do: I have a file... (0 Replies)
Discussion started by: katia
0 Replies

9. Shell Programming and Scripting

two while nested loops

for server in $(echo `cat /tmp/ScanHosts_${USERSNAME}.TXT`) do for portnumber in $(echo `cat /tmp/ScanPorts_${USERSNAME}.TXT`) do #echo ${server} ${portnumber} ... (3 Replies)
Discussion started by: SkySmart
3 Replies
hunspell(3)						     Library Functions Manual						       hunspell(3)

NAME
hunspell - spell checking, stemming, morphological generation and analysis SYNOPSIS
#include <hunspell/hunspell.hxx> /* or */ #include <hunspell/hunspell.h> Hunspell(const char *affpath, const char *dpath); Hunspell(const char *affpath, const char *dpath, const char * key); ~Hunspell(); int add_dic(const char *dpath); int add_dic(const char *dpath, const char *key); int spell(const char *word); int spell(const char *word, int *info, char **root); int suggest(char***slst, const char *word); int analyze(char***slst, const char *word); int stem(char***slst, const char *word); int stem(char***slst, char **morph, int n); int generate(char***slst, const char *word, const char *word2); int generate(char***slst, const char *word, char **desc, int n); void free_list(char ***slst, int n); int add(const char *word); int add_with_affix(const char *word, const char *example); int remove(const char *word); char * get_dic_encoding(); const char * get_wordchars(); unsigned short * get_wordchars_utf16(int *len); struct cs_info * get_csconv(); const char * get_version(); DESCRIPTION
The Hunspell library routines give the user word-level linguistic functions: spell checking and correction, stemming, morphological generation and analysis in item-and-arrangement style. The optional C header contains the C interface of the C++ library with Hunspell_create and Hunspell_destroy constructor and destructor, and an extra HunHandle parameter (the allocated object) in the wrapper functions (see in the C header file hunspell.h). The basic spelling functions, spell() and suggest() can be used for stemming, morphological generation and analysis by XML input texts (see XML API). Constructor and destructor Hunspell's constructor needs paths of the affix and dictionary files. See the hunspell(4) manual page for the dictionary format. Optional key parameter is for dictionaries encrypted by the hzip tool of the Hunspell distribution. Extra dictionaries The add_dic() function load an extra dictionary file. The extra dictionaries use the affix file of the allocated Hunspell object. Maximal number of the extra dictionaries is limited in the source code (20). Spelling and correction The spell() function returns non-zero, if the input word is recognised by the spell checker, and a zero value if not. Optional reference variables return a bit array (info) and the root word of the input word. Info bits checked with the SPELL_COMPOUND, SPELL_FORBIDDEN or SPELL_WARN macros sign compound words, explicit forbidden and probably bad words. From version 1.3, the non-zero return value is 2 for the dictionary words with the flag "WARN" (probably bad words). The suggest() function has two input parameters, a reference variable of the output suggestion list, and an input word. The function returns the number of the suggestions. The reference variable will contain the address of the newly allocated suggestion list or NULL, if the return value of suggest() is zero. Maximal number of the suggestions is limited in the source code. The spell() and suggest() can recognize XML input, see the XML API section. Morphological functions The plain stem() and analyze() functions are similar to the suggest(), but instead of suggestions, return stems and results of the morphological analysis. The plain generate() waits a second word, too. This extra word and its affixation will be the model of the morphological generation of the requested forms of the first word. The extended stem() and generate() use the results of a morphological analysis: char ** result, result2; int n1 = analyze(&result, "words"); int n2 = stem(&result2, result, n1); The morphological annotation of the Hunspell library has fixed (two letter and a colon) field identifiers, see the hunspell(4) manual page. char ** result; char * affix = "is:plural"; // description depends from dictionaries, too int n = generate(&result, "word", &affix, 1); for (int i = 0; i < n; i++) printf("%s0, result[i]); Memory deallocation The free_list() function frees the memory allocated by suggest(), analyze, generate and stem() functions. Other functions The add(), add_with_affix() and remove() are helper functions of a personal dictionary implementation to add and remove words from the base dictionary in run-time. The add_with_affix() uses a second word as a model of the enabled affixation of the new word. The get_dic_encoding() function returns "ISO8859-1" or the character encoding defined in the affix file with the "SET" keyword. The get_csconv() function returns the 8-bit character case table of the encoding of the dictionary. The get_wordchars() and get_wordchars_utf16() return the extra word characters definied in affix file for tokenization by the "WORDCHARS" keyword. The get_version() returns the version string of the library. XML API The spell() function returns non-zero for the "<?xml?>" input indicating the XML API support. The suggest() function stems, analyzes and generates the forms of the input word, if it was added by one of the following "SPELLML" syntaxes: <?xml?> <query type="analyze"> <word>dogs</word> </query> <?xml?> <query type="stem"> <word>dogs</word> </query> <?xml?> <query type="generate"> <word>dog</word> <word>cats</word> </query> <?xml?> <query type="generate"> <word>dog</word> <code><a>is:pl</a><a>is:poss</a></code> </query> The outputs of the type="stem" query and the stem() library function are the same. The output of the type="analyze" query is a string contained a <code><a>result1</a><a>result2</a>...</code> element. This element can be used in the second syntax of the type="generate" query. EXAMPLE
See analyze.cxx in the Hunspell distribution. AUTHORS
Hunspell based on Ispell's spell checking algorithms and OpenOffice.org's Myspell source code. Author of International Ispell is Geoff Kuenning. Author of MySpell is Kevin Hendricks. Author of Hunspell is Laszlo Nemeth. Author of the original C API is Caolan McNamara. Author of the Aspell table-driven phonetic transcription algorithm and code is Bjorn Jacke. See also THANKS and Changelog files of Hunspell distribution. 2011-02-01 hunspell(3)
All times are GMT -4. The time now is 07:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy