06-06-2006
If namespace pollution worries you, then your solution of using brackets is neat. The enclosed commands run in a subshell so the variables evaporate after the commands have executed - though it does mean that you can't use them again if you need to access the file later.
To cut down on the typing, you could also use your shell's filename completion mechanism or use copy/paste if you've got a capable terminal emulator.
cheers
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm trying to pass nawk a shell variable to be used in a pattern match. I can't get this work.
I'm calling nawk from a /bin/sh
echo " Input file: \c"
read var1
echo " Input: \c"
read var2
nawk -F"|" -v x=$1 ' BEGIN
$15 ~ /^'$var2'/ {print $2}' var1 {apary=$15; bparty=$23; time=$4;... (3 Replies)
Discussion started by: amon
3 Replies
2. Shell Programming and Scripting
Im running a script that runs scripts within it self and i need to pass vars made in the original script to scripts run within it and the only way i can think to do it is right the string to a file and read the file in the script (4 Replies)
Discussion started by: rcunn87
4 Replies
3. Shell Programming and Scripting
I'm trying to pass nawk a shell variable to be used in a pattern match. I can't get this work.
I'm calling nawk from a /bin/sh
I want that when somebody enters Trunk Group in variable TGR so it goes into nawk variable TG.
echo "Enter TRUNK GROUP:"
read TGR
cat... (20 Replies)
Discussion started by: wakhan
20 Replies
4. Shell Programming and Scripting
I have about 20 different variables that I need to check for null values then replace with a specific string if they are null. I've been doing this via 20 different if then statements like this:
if ; then
WIND="UUU"
fi
Is there a more elegant way to do this? The vars aren't sequential in... (6 Replies)
Discussion started by: audiophile
6 Replies
5. Shell Programming and Scripting
I have an xml file:
<AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Table1>
<Data1 10 </Data1>
<Data2 20 </Data2>
<Data3 40 </Data3>
<Table1>
</AutoData>
and I have to remove the portion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" only.
I tried using sed... (10 Replies)
Discussion started by: Gary1978
10 Replies
6. Shell Programming and Scripting
I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example:
$ mgenv.sh prod
This would set environment variables for prod
$ mgenv.sh test
This would set environment variables... (1 Reply)
Discussion started by: brtaylor73
1 Replies
7. Shell Programming and Scripting
Hi I have an issue, I want to get variables from an external file. Variable file var1=test var2-test2 I want to get these vars from another shell script. Does any one know how? (5 Replies)
Discussion started by: digitalviking
5 Replies
8. UNIX for Dummies Questions & Answers
Hi all,
I have a small Question here in Unix File System.I am unable to get a proper answer in Internet. Hope someone can get back to me soon.
A Unix file system can mount filesystem of several disk partitions to form a single global space.
Suppose that you wish to virtualize this global... (1 Reply)
Discussion started by: Pavan Kumar
1 Replies
9. Shell Programming and Scripting
Hello,
I have a tab delimited list of 311 server & account names which I want to read those 2 variables and then connect to each server and get info on that particular job account. I've tried the following:
while read server acct; do
printf "********$server\t $acct***********\n"
... (3 Replies)
Discussion started by: mcbobolink
3 Replies