Sponsored Content
Top Forums Shell Programming and Scripting replacing a number with random variable inside shell script Post 302135605 by Ygor on Tuesday 11th of September 2007 02:01:02 AM
Old 09-11-2007
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

 

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
fvwm-menu-directory(1)						  Fvwm Utilities					    fvwm-menu-directory(1)

NAME
fvwm-menu-directory - builds a directory browsing menu for fvwm SYNOPSIS
fvwm-menu-directory [ --help|-h|-? ] [ --version|-V ] [ --name|-na NAME ] [ --title|-t NAME ] [ --item|-it NAME ] [ --icon-title|-icon-t XPM ] [ --icon-dir|-icon-d XPM ] [ --icon-file|-icon-f XPM ] [ --icon-app|-icon-a XPM ] [ --wm-icons ] [ --dir|-d NAME ] [ --order|-o NUM ] [ --[no]all|-a ] [ --[no]links|-l ] [ --xterm|-x CMD ] [ --exec-title|-exec-t CMD ] [ --exec-file|-exec-f CMD ] [ --exec-app|-exec-a [CMD] ] [ --command-title|-command-t CMD ] [ --command-file|-command-f CMD ] [ --command-app|-command-a CMD ] [ --[no]reuse|-r ] [ --[no]check-subdirs|-ch ] [ --special-dirs|-s [VALUE] ] [ --[no]memory-for-speed|-mem ] [ --menu-style|-men NAME ] [ --func-name|-f NAME ] DESCRIPTION
A perl script which provides an output to read in with PipeRead to build an fvwm menu containing a directory listing. Almost everything can be configured. HINTS
The title item with its own attached action is usually added to the menu. This may be used to define an action for the directory for which the menu is built, such as starting a terminal in this directory (the default). However, this may annoy some users. To disable the title action use --command-title "", to remove the title completely use --title "". OPTIONS
--help show the usage and exit --version show version and exit --name name menu name, used only with --reuse, default is MenuBrowser --title title menu title format, default is '%*-40p' - last 40 characters of the current full path. TAB can be specified as ' ', but in .fvwm2rc you should specify a double backslash or a real TAB. Format specifiers: %d - the current directory name %p - the current directory full path These specifiers can receive an optional integer size, positive for right adjusted string or negative for left adjusted, example: %8x; and optional *num or *-num, which means to leave only the first or last (if minus) num of chars, the num must be greater than 3, since the striped part is replaced with "...", example: %*30x. Both can be combined: %-10*-20x, this instructs to get only the 20 last characters, but if the length is less then 10 - to fill with up to 10 spaces on the right. --item format menu item format, default is '%n'. TAB and width modifiers for %n, %N and %s can be specified as described in --title above. Note, specifying a non default format slows the script. Format specifiers: %n - file/dir name (without the path) %N - file/dir name (full with the path) %d - file/dir date (yyyy-mm-dd HH:MM:SS) %D - file/dir date (yyyy-mm-dd) %s - file/dir size (in bytes) %t - file/dir type (File|Dir |Link|Sock|Blck|Char|Pipe) %T - file/dir type (F|D|L|S|B|C|P) Example: --title '%*-40p Date, Type Size' --item '%*40n %d %t %s' --icon-title icon menu title icon, default is none --icon-dir icon menu dir icon, default is none --icon-file icon menu file icon, default is none --icon-app icon menu application icon, default is none --wm-icons define icon names suitable for use with wm-icons package. Currently this is equivalent to: --icon-title menu/folder-open.xpm --icon-item menu/file.xpm --icon-dir menu/folder.xpm --icon-app menu/utility.xpm. --dir dir starting dir, default is ${HOME-.} --order number in the range (-6 .. 6), default is 5: 1 - do not sort, 2 - dirs first, 3 - files first 4 - sort by name, 5 - dirs first, 6 - files first Negative number represents reverse order. --[no]all show hidden files, like in 'ls -A', default is --noall --[no]links follow linked directories, default is --nolinks --xterm command X terminal call, default is 'xterm -e' --exec-title command an fvwm Exec command on directory title (usually the shell), default is ${SHELL-/bin/sh}. '-' means no Exec command, i.e. Nop. If the command is not started with '^' X terminal call is prepended. The command is started in the currently browsed directory. --exec-file command an fvwm Exec command on regular files, default is ${EDITOR-vi}. '-' means no Exec command, i.e. Nop. If the command is not started with '^' X terminal call is prepended. The actual file name is appended to the command. --exec-app [command] an fvwm Exec command on +x files, default is '-', which means the same command as on regular files. If no command is given, it is assumed to be empty - simply run the +x file. If the command is not started with '^' X terminal call is prepended. The actual file name is appended to the command. --command-title command an fvwm command to execute on title. If this option is not given (or command is '-'), the "--exec-title" is used instead. In the command, %d is substituted with the full directory path. In fact, --exec-title=tcsh is equivalent to --command-title='Exec cd "%d"; xterm -e tcsh' The empty value disables the title action. --command-file command an fvwm command to execute on regular files. If this option is not given (or command is '-'), the "--exec-file" is used instead. In the command, %f is substituted with the full file path. In fact, --exec-file=vi is equivalent to --command-file='Exec xterm -e vi "%f"' --command-app command an fvwm command to execute on +x files. If this option is not given (or command is '-'), the "--command-app" is used instead. In the command, %f is substituted with the full file path. In fact, --exec-app=^exec is equivalent to --command-app='Exec exec "%f"' --[no]reuse no pop-up menus, reuse the same menu, default is --noreuse. When you specify this option the Menu action is used, not Popup. Also, the --name parameter is not ignored, and --dir parameter is ignored if there is ~/.fvwm/.fvwm-menu-directory.dir file. This file is only created or used with this option specified, it is the only solution for the current fvwm menu state. --[no]check-subdirs check all subdirs for having execute (+x) permission and replace "Popup"/"Menu" command with "Nop" for these without permissions. This has a visual effect of disabling popup triangle in the subdirectory item. The default is --nocheck-subdirs, because: 1) enabling this slows a bit the script, 2) with this option enabled, if no icons used and no dir/file separate sorting used there is no way to know that the item is directory and not file. --special-dirs value add .. or ~ or / special directories according to given optional value. Without with option these directories are not added. Default value if not specified is "1,2". The value is comma separated ordered special directory indexes, where 1 is parent directory, 2 is home directory, 3 is root directory. If minus is prepended to the value, special directories are added at the bottom of menu instead of top. Value "0" or any bad value is equivalent to non-specifying this option at all. --[no]memory-for-speed use speed optimization, i.e. use previously created directory menus without destroying it when closed, default is --nomemory-for-speed Warning: speed optimization takes up a lot of memory that is never free'd again while fvwm is running. --menu-style name assign MenuStyle name to the menus --func-name name overwrite the default MissingSubmenuFunction name that is "FuncFvwmMenuDirectory" Option parameters can be specified either using '=' or in the next argument. Short options are ok if not ambiguous: "-a", "-x", "-icon-f"; but be careful with short options, what is now unambiguous, can become ambiguous in the next versions. USAGE
Put this into your fvwm configuration file to invoke the script: AddToFunc FuncFvwmMenuDirectory + I PipeRead "fvwm-menu-directory -d '$0'" More complex example: # AddToFunc FuncFvwmMenuDirectory # + I PipeRead "fvwm-menu-directory -d '$0' -x 'Eterm -g 80x40 -e' \ -a -l -o 6 --exec-app --exec-title 'tcsh -l' --exec-file 'vim -R' \ -t 'Go to: %d' --wm-icons" And put this in the menu from which you want to pop-up the directory menus: AddToMenu SomeMenu MissingSubmenuFunction FuncFvwmMenuDirectory + "Home Directory" Popup $[HOME] + "Httpd Directory" Popup /home/httpd Note: please use absolute path names. It is a good idea to set the menu pop-up delay to something positive and enable busy cursor MenuStyle * PopupDelayed, PopupDelay 200 BusyCursor DynamicMenu True in your configuration file when using this script for better results. Another interesting usage ("--reuse" or "-r" is mandatary for this): AddToMenu Browser + DynamicPopupAction PipeRead \ "fvwm-menu-directory -r -na Browser -d / -s" AddToMenu SomeMenu "My Browser" Menu Browser Here the "--dir" parameter (starting directory) is ignored if there is ~/.fvwm/.fvwm-menu-directory.dir file, which you can delete. AUTHORS
Inspired on 1999-06-07 by Dominik Vogt <domivogt@fvwm.org>. Rewritten on 1999-08-05 by Mikhael Goikhman <migo@homemail.com>. COPYING
The script is distributed by the same terms as fvwm itself. See GNU General Public License for details. BUGS
Report bugs to fvwm-bug@fvwm.org. 2.5.28 (from cvs) 2009-03-22 fvwm-menu-directory(1)
All times are GMT -4. The time now is 03:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy