09-11-2007
replacing a number with random variable inside shell script
Hi All.
I need help for the below logic.
I ve a file like following
input file:
NopTX(5) // should be remain same as input
----Nop(@100); //1
Nop(90); //2
--Nop(80); //3
@Nop(70); //4
--@Nop(60); //5
@Nop@(@50); //6
--Nop@( 40); //7
Nop(@-30); //8
@ represents tab space and
- represents a single space
I want to change the file as follows
output
NopTX(5) // should be remain same as input
----Nop(@500); //1
Nop(450); //2
--Nop(400); //3
@Nop(350); //4
--@Nop(300); //5
@Nop@(@250); //6
--Nop@( 200); //7
Nop(@-150); //8
Basically the number inside the "()"is changed to five times than the input file.
I ve written a programme as follows but then I m facing problem with "how to replace that variable temp in the input file
#!/bin/sh
for ttt in `find . -name "*.file" -print `
do
awk '
/^[ \t]*Nop[ \t]*\(/{
split($0, a, /\(|\)/)
temp = a[2]*5
} ' Nop
done
Please help if any idea.
Regards
user_prady
Last edited by user_prady; 09-13-2007 at 10:57 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I want to be able to generate a random number within a korn shell script..
Preferably i would like to be able to state how many digits should be in this random number... ie 4 digits or 5 digits etc
Any ideas? (2 Replies)
Discussion started by: frustrated1
2 Replies
2. Shell Programming and Scripting
I have a continous polling happening inside a shell script on AIX. This actually calls a PL/SQL block. Is there a way I can set up a variable or pass an interrupt to end the script gracefully. I cant read from the config once the job starts running. Ideally I should change value of a variable and... (1 Reply)
Discussion started by: kshyju
1 Replies
3. Shell Programming and Scripting
Hello,
The following sed command is giving error
sed: -e expression #1, char 13: unknown option to `s'
The sed command is
echo "//-----" | sed "s/\/\/---*/$parChk/g"
where parChk="//---ee-"
How can i print the variable value from sed command ?
And is it possible to replace a... (2 Replies)
Discussion started by: frozensmilz
2 Replies
4. Shell Programming and Scripting
hi all,
i'm using the following script,
Status=1
Function_do ()
{
while read line;
do
if ; then
#echo $line
if ; then
Status=0
echo " LINKINK ERROR "
fi
fi
done < ldd.log
}
Function_do (4 Replies)
Discussion started by: vij_krr
4 Replies
5. Shell Programming and Scripting
Hi folks
I'm coding on Ubuntu 9.04 standard shell.
I'm writing a script that needs to generate a random number at some point of its execution.
When I do
echo $RANDOMas a command inside shell, I clearly get some randomly generated number
However when I do
i=`$RANDOM`
echo $ior even... (14 Replies)
Discussion started by: ksk
14 Replies
6. Shell Programming and Scripting
Hi all
I run my program prog.c in the following way :
$ ./prog 1 > output.txt where 1 is a user defined initial value used by the program.
But now I want to run it for many a thousand initial values, 1-1000, and store all the outputs in different files.
Like
$ ./prog 1... (1 Reply)
Discussion started by: alice06
1 Replies
7. Shell Programming and Scripting
Hallo,
im basically a complete noob on shell scripting and im trying to replace or rather add 1 to a number between xml tags.
The xml basically has a tag somewhere that looks like this:
<tag>12345678901234</tag>
Now i want to replace the number between the tags. And i want the file to... (6 Replies)
Discussion started by: Demoric
6 Replies
8. Shell Programming and Scripting
Having a hard time with this. Very new to scripting and linux. Spent all sunday trying to do this. Appreciate some help and maybe help breaking down what the syntax does.
Create a Bash program. It should have the following properties
• Creates a secret number between 1 and 100
i. The... (3 Replies)
Discussion started by: LINUXnoob15
3 Replies
9. UNIX for Beginners Questions & Answers
I have if loop with multiple variable value check in if loop. How can i print only if loop satisfied variable and its value in shell script ? I dont want to check each variable in if loop. That makes my script larger.
if ]
then
echo "Only satisfied variable with value"
... (3 Replies)
Discussion started by: prince1987
3 Replies
10. OS X (Apple)
Hi all...
Apologies for any typos, etc...
This took a while but it didn't beat me...
Although there are many methods of generating random numbers in a POSIX shell this uses integer maths and a simple C source to create an executable to get epoch to microseconds accuracy if it is needed. I take... (8 Replies)
Discussion started by: wisecracker
8 Replies