Sponsored Content
Top Forums Shell Programming and Scripting Can I use $1 several times in shell program? Post 55545 by zazzybob on Tuesday 14th of September 2004 11:58:46 AM
Old 09-14-2004
Hmmm... You're doing something strage here.

You're grabbing the value for name if $1 is empty. Fine. But then you're
saying if $1 is empty (which it still will be), then set name="", i.e.
lose the value it was just set to?!

Anyway, yes, $1 can be referenced as many times as you want, as long as you're
not trying to reference it inside of a function.

I'd personally save $1 to a variable within the program, i.e. "first_arg=$1" or
whatever.

Cheers
ZB
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

One shell script --2 parts need to execute during different times

Hi All, Have one job . first part of it needs to run on five days of the week , while second part of the job needs to run on two days of the week. How do I go abt this? Thanks (2 Replies)
Discussion started by: cbecentral
2 Replies

2. UNIX for Advanced & Expert Users

Checking mem usage at specific times in a program

Hi all, I'm running a simulator and I'm noticing an slow increase in memory for long simulations such that the simulation has to end because of a lack of memory. A colleague of mine ran Valgrind memcheck and reported that nothing of interest was reported other than known mem leaks. My advisor... (2 Replies)
Discussion started by: pl4u
2 Replies

3. Shell Programming and Scripting

[bash] Run a program many times

Hi I'm running a program many times with differents input. I mean that i run my_prog with some parameters and i wait till the end, then i start again another simulations with some others differents parameters. Is possible to make it automatic with a script bash. Maybe i need some... (2 Replies)
Discussion started by: Dedalus
2 Replies

4. Shell Programming and Scripting

Shell script to run x times

Hi, First i need to cd to this directory $SWDIR/util Second i need to run the following either 4 times or 20 times ./swadm add_process 1 BG Y how can i put this in a script which should ask for user input on how many times you want to run this Thanks, (5 Replies)
Discussion started by: lookinginfo
5 Replies

5. UNIX for Dummies Questions & Answers

script help shell session times out

while read s1 ; do url= suf=ignore=.csv; wget $url$s1$suf; sleep 5; cat /home/joey/public_html/charts/program/fn\charts/data/tickers/header.txt > $s1.txt; chmod 777 $s1.txt; sed '1d' table.csv?s\=$s1 >> /home/joey/public_html/charts/program/charts/data/tickers/$s1.txt; rm -Rf... (0 Replies)
Discussion started by: harte
0 Replies

6. Programming

Problem with implementing the times() function in C (struct tms times return zero/negative values)

Hello, i'm trying to implement the times() function and i'm programming in C. I'm using the "struct tms" structure which consists of the fields: The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling process. The tms_stime structure... (1 Reply)
Discussion started by: g_p
1 Replies

7. Programming

Compare times to run a program - Serial vs MPI

Hi, I have a fortran program with serial and MPI version. I want to compare the time taken by these programs to run. I use ifort/gfortran compiler. How to compare the time taken by each program to run? Is there any sample code for comparison? Thanks, rpd (1 Reply)
Discussion started by: rpd25
1 Replies

8. Shell Programming and Scripting

Tabbing a line a variable number of times in shell

Hi, I had another question. I was wondering if there was a way to tab a line a variable number of times in tcsh. To go into details, I want to tab a line by how deep a file is in its path. So here is an example code: set filea=/blah1/blah2/blah3 set fileb=/blah1/blah2/blah3/blah4 set... (4 Replies)
Discussion started by: chu816
4 Replies

9. UNIX for Dummies Questions & Answers

shell program- how many times a function is called

We have a program source C and is required to indicate how many times each function is called from the C program. also print the line number where there is a call. I've tried something like this: #!/bin/sh for i in $*;do if ! then echo $i is not a C file. else echo $i... (0 Replies)
Discussion started by: oana06
0 Replies

10. Shell Programming and Scripting

Running a program multiple times to search pattern and assign structure

Hi all, I have a big file (n.txt) with following pattern: ATOM 1 N SER A 1 122.392 152.261 138.190 1.00 0.00 N ATOM 2 CA SER A 1 122.726 151.241 139.183 1.00 0.00 C TER ENDMDL ATOM 1 N SER A 1 114.207 142.287 135.439 1.00 0.00 ... (3 Replies)
Discussion started by: bioinfo
3 Replies
Utils(n)						       Tix Built-In Commands							  Utils(n)

__________________________________________________________________________________________________________________________________________________

NAME
tixUtils - Utility commands in Tix. SYNOPSIS
tixDescendants pathName tixDisableAll pathName tixEnableAll pathName tixPushGrab ?-global? window tixPopGrab _________________________________________________________________ DESCRIPTION
tixDescendants pathName Returns a list of all the descendant widgets of pathName plus pathName itself. tixDisableAll pathName Disables pathName and all its descendants. tixEnableAll pathName Enables pathName and all its descendants. tixPushGrab ?-global? window The tixPushGrab and tixPopGrab commands allows you to perform "cascade-grabbing". tixPushGrab calls the grab(n) command on window and saves window on a grabbing stack. tixPopGrab tixPopGrab pops the top-most element from the grabbing stack and release its grab. If the grabbing stack is not empty, then tixPop- Grab will execute grab(n) on the current top-most element in the grabbing stack. NOTES
Some Tix widgets (for example, tixComboBox and tixPanedWindow) grabs the screen on certain occasions using tixPushGrab and tixPopGrab. Therefore, if you need to grab the screen when these widgets are present, you should also call tixPushGrab and tixPopGrab in place of the Tk grab and grab release commands. Otherwise, the behavior of these widgets may be undefined. KEYWORDS
Tix(n), grab(n) Tix 4.0 Utils(n)
All times are GMT -4. The time now is 04:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy