Sponsored Content
Full Discussion: env file
Top Forums UNIX for Dummies Questions & Answers env file Post 9052 by Perderabo on Monday 22nd of October 2001 10:03:36 AM
Old 10-22-2001
I put my .env file in my home directory, but there's a little more to it.

My .env file defines a bunch of functions and aliases that I want available in all of my interactive shells. On the other hand, I would prefer that my ksh scripts ignore the .env file since they do not need the aliases and it would slow them down. This is a common situation and I use the standard ksh trick to address it:
Code:
FILE=$HOME/.env
ENV='${FILE[(_$-=1)+(_=0)-(_$-!=_${-%%*i*}}]}'
export ENV FILE

This treats FILE as an array where only ${FILE[0]} has a value. That complex subscript computes to 0 for interactive shells and to 1 for non-interactive shells. This trick originates with Dr. Korn himself. It's in his book.
 

10 More Discussions You Might Find Interesting

1. Programming

File Opening in C++ in Unix Env

Pls someone help me. This piece of code is giving me weird results. ofstream outfile; ofstream out; char filename1; char filename2; memset(filename1,'\0',sizeof(filename1)); memset(filename2,'\0',sizeof(filename2)); strcpy(filename1,"Testing1.out");... (0 Replies)
Discussion started by: skannan
0 Replies

2. Shell Programming and Scripting

set env in login file

Hi, I have inserted the following line in my local.login file setenv ORACLE_HOME /u01/app/oracle/product/8.1.7 Then when I do an echo $ echo $ORACLE_HOME I get a blank line. Am I setting up ORACLE_HOME incorrectly? Thanx (3 Replies)
Discussion started by: nattynatty
3 Replies

3. Shell Programming and Scripting

Adding command line env in cron env

Hello friends, i run two scripts manually & they work. i run them in cron & they don work. how to match the two env's 1.command line env 2.cron env i would like cron to use command line env. Thanks & Regards Abhijeet (1 Reply)
Discussion started by: abhijeetkul
1 Replies

4. UNIX for Advanced & Expert Users

How to edit env file

A coworker of mine wants to add some environment variables to env file. Please advise how to do it. He couldn't use: more or vi on the file. Thanks. (3 Replies)
Discussion started by: duke0001
3 Replies

5. UNIX for Dummies Questions & Answers

Get file from window env

Hi, I can use rcp to copy a file from unix to window. How can I get a file from window env in unix. Ivan (1 Reply)
Discussion started by: egckhad
1 Replies

6. Shell Programming and Scripting

exporting variabels from env file

I am running a unix script and calling an env script with in that. but the variables i am exporting in env are not being used by the present script. can any body let me know why? The env file is in the same directory and when i run in devug mode its able to show all the variable values also. ... (1 Reply)
Discussion started by: dsravan
1 Replies

7. Shell Programming and Scripting

Identify env file called

Hi, please help me.. in how to find out which env file is being called upon when an os user logs. when i su - oracle , i would like to know which env is called, because i see many env files under the home dir.. thanks, (2 Replies)
Discussion started by: jjoy
2 Replies

8. Shell Programming and Scripting

Add env variable in a file

Hi, I have a small requirement set -x `grep IMPACT_HOME=/opt/impact /opt/NETCOOLINST/r.txt | cut -d'=' -f2` if ; then sed 's#IMPACT_HOME=*#d' /opt/NETCOOLINST/r.txt echo "IMPACT_HOME=" >> /opt/NETCOOLINST/r.txt sed 's#IMPACT_HOME=*#IMPACT_HOME=/opt/impact#g' /opt/NETCOOLINST/r.txt... (2 Replies)
Discussion started by: dbashyam
2 Replies

9. Web Development

Deny from env=env-variable Does not work

(Above from Apache docs). On my system, using: SetEnvIf User-Agent Mozilla IsBad=1 Order allow,deny Allow from all Deny from env=IsBad ...I see that environment variable is set (using phpinfo()) but the page is still served. No errors in the Apache logs. (1 Reply)
Discussion started by: gnurob
1 Replies

10. UNIX for Dummies Questions & Answers

Env file path

Hi, when I run "env" there are few variable prinitng related to application $env SRV=test NVV=test2 from where this file is invoking, I checked in ./bash_profile and ./profile didn't find the variable. So what is the file I need to edit this variable. (8 Replies)
Discussion started by: stew
8 Replies
ENV(1)                                                             User Commands                                                            ENV(1)

NAME
env - run a program in a modified environment SYNOPSIS
env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...] DESCRIPTION
Set each NAME to VALUE in the environment and run COMMAND. Mandatory arguments to long options are mandatory for short options too. -i, --ignore-environment start with an empty environment -0, --null end each output line with NUL, not newline -u, --unset=NAME remove variable from the environment -C, --chdir=DIR change working directory to DIR --help display this help and exit --version output version information and exit A mere - implies -i. If no COMMAND, print the resulting environment. AUTHOR
Written by Richard Mlynarik and David MacKenzie. REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report env translation bugs to <http://translationproject.org/team/> COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
Full documentation at: <http://www.gnu.org/software/coreutils/env> or available locally via: info '(coreutils) env invocation' GNU coreutils 8.28 January 2018 ENV(1)
All times are GMT -4. The time now is 12:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy