Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hello , my first question is
i) i have made a new script in this script i have a variable called found , in this script i call a subscript and i want that this subscript change the value of my variable if needed, i tried to export it but without effort do anyone have an ideaii)again i am calling the same script with some argument in the script i want to store the number of arguments in a variable called number , how can i do this

well i have tried to solve the following
number= $* | wc -w but it has give error how to do it help people

i) I'm not sure from your description, but I think you are trying to capture the output of another shell script. You normally use command substitution to capture the output of a command.
Assume your shell script named subscript is in the same directory and contains this one line:
echo "helloworld"
Now, in your main script, using korn or bash shell, execute subscript within $():
#!/bin/bash
found=$(./subscript)
echo "$found" # should be helloworld# the older bourne shell uses backtics for command substitution:
found=`./subscript`
echo "$found"ii) the $# variable contains the number command line arguments
echo "number of args: $#"

hi nails i am very proud of your answers but i think i asked the question in a wrong manner, for the first question i am writing a sort algorithm i get each line of the text one by one and i send the line as argument to the subscript , and i have a variable called found in the main script, the subscripts checks whethe a keyword matches with any word in the line which is send as an argument to the subscript, i want, if there is a match between a word in the line and the keyword, found to increase one, if no match then it will stay unchanged, and the end when all lines checked , i want found to contain number of matches, so while i tried the found has not changed when i use export option it makes the variable read only, so that is the first question
ii) the second one i hope i solved i just want the output of the echo which is a number in my case i.e. i make echo $x + $y (or any expression) to be stored in a variable called $number so that i can make arithmetical operations on it, for this purpose i found that
number= ' echo ls | wc -w '
i tried it worked it assigns the output of the wc command to the variable number, if anyone knows any shortcut method better than i would like to know

Thanks for your sharing. Thanks for sharing this useful information. It's great.
[url=http://sonneriegratuite.org/][color=#FFFFFF][u]gratuit pour mobile sonnerie portable mp3[/u][/color][/url][color=#FFFFFF] - Sonnerie portable MP3 est en effet un pouvoir de l'innovation technologique. Êtes-vous familier avec cette sonnerie portable?[/color][url=http://sonneriegratuite.org/][color=#FFFFFF][u]gratuit pour mobile sonnerie portable mp3[/u][/color][/url]

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |