Sponsored Content
Full Discussion: Variables scope.
Top Forums Shell Programming and Scripting Variables scope. Post 302198417 by abhisek.says on Friday 23rd of May 2008 12:44:30 AM
Old 05-23-2008
Bug checking for file existence first

Hi,

First yo chech for the file existence and then

FLAG=0;
while read file
do
FLAG =1;
done < input_file
echo "$FLAG"

I think this should work...
 

10 More Discussions You Might Find Interesting

1. Programming

C++: scope, different files etc..

I'm having a problem getting this to work.. I got 3 files, start.C - Where i got my main() function Menu.C & Menu.h - Where I'm trying to use hash_map start.C #include <iostream> #include "Menu.h" using namespace std; int main() { /* test code here */ return 0; } Menu.h ... (1 Reply)
Discussion started by: J.P
1 Replies

2. Programming

scope

Each thread has a copy of auto variables within a function, but variables declared as static within a function are common to all threads. To circumvent this can static variables be placed outside the function. If so, will the scope of the variable be file only or will it be extern, and will each... (7 Replies)
Discussion started by: sundaresh
7 Replies

3. UNIX for Advanced & Expert Users

Access Awk Variables Outside Scope

Sorry in the wrong forum. Moving this to right forum. (2 Replies)
Discussion started by: Amruta Pitkar
2 Replies

4. Shell Programming and Scripting

Access Awk Variables Outside Scope

My awk script searches for specified patterns in a text file and stores these values into mem variables. Once this is done I want to Insert these values into a table. How can I avail of the variable values outside the scope of awk script.... One method that I have tried is to write the... (7 Replies)
Discussion started by: Amruta Pitkar
7 Replies

5. Shell Programming and Scripting

Doubt??? [scope of variables]

Heres an example..... <~/abc>$ cat textfile line 1 line 2 line 3 line 4 line 5 <~/abc>$ cat try.sh #/bin/ksh for runs in 1 2 3 do A=$runs echo "Inside A : $A" done echo "Outside A : $A" <- works fine (1 Reply)
Discussion started by: qzv2jm
1 Replies

6. AIX

Scope of AIX

What is the scope of AIX as I am starting my career as a fresher in AIX administration?? (4 Replies)
Discussion started by: abhishek27
4 Replies

7. Shell Programming and Scripting

Doubt about variables scope

I call my script with two parameters myscript.sh aaa bbb What is the way to access $1 and $2 values inside a function? I call the function like this myfuntion $1 $1 but inside of the function, $1 and $2 are empty. Any suggestions? thank you in advanced. (1 Reply)
Discussion started by: aristegui
1 Replies

8. Shell Programming and Scripting

while read loop; scope of variables (shell)

If I set a variable within a while-read loop, sometimes it's local to the loop, sometimes it's global, depending on how the loop is set up. I'm testing this on a Debian Lenny system using both bash and dash with the same results. For example: # Pipe command into while-read loop count= ls -1... (2 Replies)
Discussion started by: mjd_tech
2 Replies

9. Shell Programming and Scripting

variable scope

Hi, I want to know about the variable scope in shell script. How can we use the script argument inside the function? fn () { echo $1 ## I want this argument should be the main script argument and not the funtion argument. } also are there any local,global types in shell script? if... (3 Replies)
Discussion started by: shellwell
3 Replies

10. Shell Programming and Scripting

Scope of variables between scripts

Friends, I am using ksh under SunoS. This is what I have In file1.sh NOW=$(date +"%b-%d-%y") LOGFILE="./log-$NOW.log" I will be using this file through file1.sh as log file. I have another script file2.sh which is being called inside my file1.sh. I would like to use the same log... (6 Replies)
Discussion started by: dahlia84
6 Replies
IP-ADDRESS(8)							       Linux							     IP-ADDRESS(8)

NAME
ip-address - protocol address management SYNOPSIS
ip [ OPTIONS ] address { COMMAND | help } ip address { add | del } IFADDR dev STRING ip address { show | flush } [ dev STRING ] [ scope SCOPE-ID ] [ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ] IFADDR := PREFIX | ADDR peer PREFIX [ broadcast ADDR ] [ anycast ADDR ] [ label STRING ] [ scope SCOPE-ID ] SCOPE-ID := [ host | link | global | NUMBER ] FLAG-LIST := [ FLAG-LIST ] FLAG FLAG := [ permanent | dynamic | secondary | primary | tentative | deprecated | dadfailed | temporary ] DESCRIPTION
The address is a protocol (IP or IPv6) address attached to a network device. Each device must have at least one address to use the corre- sponding protocol. It is possible to have several different addresses attached to one device. These addresses are not discriminated, so that the term alias is not quite appropriate for them and we do not use it in this document. The ip address command displays addresses and their properties, adds new addresses and deletes old ones. ip address add - add new protocol address. dev NAME the name of the device to add the address to. local ADDRESS (default) the address of the interface. The format of the address depends on the protocol. It is a dotted quad for IP and a sequence of hexa- decimal halfwords separated by colons for IPv6. The ADDRESS may be followed by a slash and a decimal number which encodes the net- work prefix length. peer ADDRESS the address of the remote endpoint for pointopoint interfaces. Again, the ADDRESS may be followed by a slash and a decimal number, encoding the network prefix length. If a peer address is specified, the local address cannot have a prefix length. The network prefix is associated with the peer rather than with the local address. broadcast ADDRESS the broadcast address on the interface. It is possible to use the special symbols '+' and '-' instead of the broadcast address. In this case, the broadcast address is derived by setting/resetting the host bits of the interface prefix. label NAME Each address may be tagged with a label string. In order to preserve compatibility with Linux-2.0 net aliases, this string must coincide with the name of the device or must be prefixed with the device name followed by colon. scope SCOPE_VALUE the scope of the area where this address is valid. The available scopes are listed in file /etc/iproute2/rt_scopes. Predefined scope values are: global - the address is globally valid. site - (IPv6 only) the address is site local, i.e. it is valid inside this site. link - the address is link local, i.e. it is valid only on this device. host - the address is valid only inside this host. ip address delete - delete protocol address Arguments: coincide with the arguments of ip addr add. The device name is a required argument. The rest are optional. If no arguments are given, the first address is deleted. ip address show - look at protocol addresses dev NAME (default) name of device. scope SCOPE_VAL only list addresses with this scope. to PREFIX only list addresses matching this prefix. label PATTERN only list addresses with labels matching the PATTERN. PATTERN is a usual shell style pattern. dynamic and permanent (IPv6 only) only list addresses installed due to stateless address configuration or only list permanent (not dynamic) addresses. tentative (IPv6 only) only list addresses which have not yet passed duplicate address detection. deprecated (IPv6 only) only list deprecated addresses. dadfailed (IPv6 only) only list addresses which have failed duplicate address detection. temporary (IPv6 only) only list temporary addresses. primary and secondary only list primary (or secondary) addresses. ip address flush - flush protocol addresses This command flushes the protocol addresses selected by some criteria. This command has the same arguments as show. The difference is that it does not run when no arguments are given. Warning: This command (and other flush commands described below) is pretty dangerous. If you make a mistake, it will not forgive it, but will cruelly purge all the addresses. With the -statistics option, the command becomes verbose. It prints out the number of deleted addresses and the number of rounds made to flush the address list. If this option is given twice, ip address flush also dumps all the deleted addresses in the format described in the previous subsection. EXAMPLES
ip address show dev eth0 Shows the addresses assigned to network interface eth0 ip addr add 2001:0db8:85a3::0370:7334/64 dev eth1 Adds an IPv6 address to network interface eth1 ip addr flush dev eth4 Removes all addresses from device eth4 SEE ALSO
ip(8) AUTHOR
Original Manpage by Michail Litvak <mci@owl.openwall.com> iproute2 20 Dec 2011 IP-ADDRESS(8)
All times are GMT -4. The time now is 04:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy