Sponsored Content
Top Forums Shell Programming and Scripting replacing a number with random variable inside shell script Post 302135614 by user_prady on Tuesday 11th of September 2007 02:30:16 AM
Old 09-11-2007
Quote:
Originally Posted by Ygor
Try...
Code:
$ cat file1
NopTX
----Nop(@100); //1
Nop(90); //2
--Nop(80); //3
@Nop(70); //4
--@Nop(60); //5
@Nop@(@50); //6
--Nop@( 40); //7
Nop(@-30); //8

$ awk -F '\\([-@ ]*|\\)' 'NF==3{sub($2,$2*5)};1' file1
NopTX
----Nop(@500); //1
Nop(450); //2
--Nop(400); //3
@Nop(350); //4
--@Nop(300); //5
@Nop@(@250); //6
--Nop@( 200); //7
Nop(@-150); //8


Cool Dude......Thanks for your kind help..
Regards,
PaddySmilie

Last edited by user_prady; 09-14-2007 at 07:36 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

generate random number in korn shell

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

Changing value of a variable inside a shell script

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

Need help in sed command ( Replacing a pattern inside a file with a variable value )

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

scope of a Variable inside shell script

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

$RANDOM does not work inside a shell script

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

How to give a variable output name in a shell script inside a for loop

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

Replacing number between xml tags with ksh shell script

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

Random number generating script?

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

How to write a Boolean variable which succeed and failed inside the if loop in shell script ?

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)

Generate a random number in a fully POSIX compliant shell, 'dash'...

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
FvwmAuto(1)							   Fvwm Modules 						       FvwmAuto(1)

NAME
FvwmAuto - the fvwm auto-raise module SYNOPSIS
Module FvwmAuto Timeout [-passid] [-menter|-menterleave|-mfocus] [EnterCommand [LeaveCommand]] FvwmAuto can only be invoked by fvwm. Command line invocation of the FvwmAuto will not work. DESCRIPTION
The FvwmAuto module is most often used to automatically raise focused windows. INVOCATION
The correct syntax is: Module FvwmAuto Timeout [-passid] [-menter|-menterleave|-mfocus] [EnterCommand [LeaveCommand]] AddToMenu Modules + "Auto Raise (300 ms)" Module FvwmAuto 300 + "Auto Raise/Lower" Module FvwmAuto 300 "Silent Raise" "Silent Lower" The Timeout argument is required. It specifies how long a window must retain the keyboard input focus before the command is executed. The delay is measured in milliseconds, and any integer greater than zero is valid. If the literal option -passid is given, the window id of the window just entered or left is appended to the command that is sent to fvwm. This can be used with the WindowId command of fvwm. The options -menter, -menterleave and -mfocus influence the actions FvwmAuto reacts to. No more than one of the options can be chosen. In -mfocus mode, FvwmAuto raises the window that has the focus. In -menter mode, FvwmAuto raises the window under the pointer when the pointer enters a window. The LeaveCommand is executed on the window that was below the pointer before it entered the new window. When the pointer leaves a window and enters the root window, the EnterCommand is executed too, but without a window to operate on. In -menterleave mode, FvwmAuto works just like in -menter mode, but the LeaveCommand is also executed if the pointer moves out of a window but does not enter a new window. The latter two modes of operation are useful with windows that do not accept the focus. Note: -menterleave mode can interfere with popup windows of some applications. One example is the zoom menu of Ghostview. Please do not complain about this to us - it is a bug in Ghostview. EnterCommand and LeaveCommand are optional. EnterCommand is executed Timeout milliseconds after a window gets the input focus, LeaveCom- mand is executed Timeout milliseconds after the window has lost focus. Note that you always should use the 'Silent' keyword before the command itself. FvwmAuto prepends "Silent " to the command string on its own if yor forget this. Without this prefix fvwm would ask you for a window to act on if the window has died before the command sent by FvwmAuto has been processed by fvwm. This can for example happen with popup menus. "Silent Raise" is the default for EnterCommand, but any fvwm function is allowed. I would not use "Close" or "Destroy" with a low timeout, though. The LeaveCommand can be handy for a tidy desktop. Experiment with: Module FvwmAuto 0 Nop "Silent Lower" Module FvwmAuto 0 Nop "Silent Iconify" An example for auto raising windows with ClickToFocus: Style * ClickToFocus FvwmAuto 0 -menter "Silent Raise" An example for auto raising and lowering only some windows: To start FvwmAuto: FvwmAuto 0 -passid -menter "Silent selective_raiselower raise" "Silent selective_raiselower lower" And put this in your .fvwm2rc: AddToFunc selective_raiselower + I WindowId $1 (FvwmIconMan) $0 + I WindowId $1 (FvwmButtons) $0 + I WindowId $1 (xclock) $0 More complex example (three FvwmAuto's are running): DestroyFunc RestoreIconified AddToFunc RestoreIconified + I Current (Iconic) Iconify false DestroyFunc RegisterFocus AddToFunc RegisterFocus + I Exec date +"%T $n focused" >>/tmp/focus-stats.txt DestroyFunc RegisterUnfocus AddToFunc RegisterUnfocus + I Exec date +"%T $n unfocused" >>/tmp/focus-stats.txt KillModule FvwmAuto Module FvwmAuto 250 Raise Nop Module FvwmAuto 800 RestoreIconified Nop Module FvwmAuto 0 RegisterFocus RegisterUnfocus NOTES
There is a special Raise/Lower support in FvwmAuto. It was added to improve Raise/Lower callbacks, since most of FvwmAuto usages is auto- raising or auto-lowering. This improvement includes locking on M_RAISE_WINDOW and M_LOWER_WINDOW packets and not raising/lowering explic- itly raised windows. The special Raise/Lower support is enabled only when either EnterCommand or LeaveCommand contain substring "Raise" or "Lower". You can use this fact to enable/disable any special support by renaming these commands, if FvwmAuto does not automatically do want you expect it to do. Using FvwmAuto in conjunction with EdgeCommand can be even more powerful. There is a short example in the fvwm man page. AUTHOR
FvwmAuto just appeared one day, nobody knows how. FvwmAuto was simply rewritten 09/96, nobody knows by whom. 3rd Berkeley Distribution 09 May 2010 (2.5.30) FvwmAuto(1)
All times are GMT -4. The time now is 02:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy