Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am facing a serious problem.Please tell me what is my mistake?
My script goes like :
#!/bin/ksh
for file in send*.log
do
if[ -f ${file}]
then
grep "filename inside the file" ${file} >> temp
grep "process number" ${file} >> temp
assigning variable:
set pnum=cat temp|tail-1 temp #temp has both filename & process number
echo " $pnum " #has to display pnum from temp
main script:
set -v
ndmcli EOJ
select statistics pnumber=${pnum};#here above pnum value is not assigned. why this problem does it requires any conversion from file output to assign
EOJelse
exit
fi
doneI need to execute the above statement very badly:
select statistics pnumber=${pnum};
if give value user input ,it assigns.
but as a file output,it doesn't assignhelp me
tell me what wrong i did
thank u
nanda_anu

There's a good thought. If no one answers your homework question immediately, post it 10 or 15 more times under different names. Hope that works out for you.
BTW you don't need to check for the existence of a file you just got from the for command.

Even after removing if statement also
my variable is not assigned inside the scriptTry to give solution:
in order to assign the value of a variable
in the following
select statistics pnumber=<pnum>;
my pnum value should be ex:16244 from an another file

You set a variable in ksh with
var=value
not
set var=value
To evaluate a command and retrieve its value, use
var=$(command...)
tail returns the last n lines of a file. "cat filename | tail" does the same thing but less efficiently and with more typing.

Please post a sample of your data file. We will be able to provide you with a better answer.
for file in `find . -type f -name "send*.log" -exec grep -l pattern {} \; ` ; do
pnum=`process number' $file
done

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |