This sed command inserts (i) a line 'IMPACT_HOME=/my/new/path' before every line in infile; which is almost certainly not what you want.
You may want to make #1 look like:
which will append (a) the line at the end of file ($).
#2 is a little trickier. I think the intention was to substitute the definition of IMAPCT_HOME with a new path, however, this is a not quite well designed solution. The sed command there will replace any occurence of IMPACT_HOME until the end of line with 'IMPACT_HOME=/my/new/path'.
But what if infile contains some other statements containing IMPACT HOME, that are not a definition of it? E.g.:
would change into
and create syntax error(s).
I'd write #2 like this:
Which will change the first line containing 'IMPACT_HOME='.
It will put the old definition (string after equal sign) into a comment on the same line. So, e.g. line:
will become
It will only change (at most) one line (no 'g' at the end); and it will not change lines containing pound symbol before IMPACT_HOME (comments).
#1 and #2 can actually be put together into one (albeit long) line:
I tried your below commands but I could not see the result that I intend to.
1. I have this file .bash_profile
2. Currently I don't have any IMPACT_HOME variable inside this file. I want to add a variable with the path, I tried your #2 but it did not add the variable into the file.
I just wanted to know say the IMPACT_HOME variable is not there then what modification I need to do with the sed command? You suggested me in case if the variable is there then yes your command works fine. If its not there how to add it and add the path to it?
Not sure if I had to add anything apart from the command you have given
It works for me:
What system are you on? Can you please post output of
Invoke the command without the '-i' switch in sed, so that the output goes to terminal. Does it append the line?
Do you have write permissions on that file? I assume you would, if it is your .bash_profile, but please check.
Hello everyone,
I'm trying to set my .bash_profile to change my primary prompt from this:
banbatchtest1v:MCPPRD:~>to this:
banbatchtest1v:MCPPRD:/home/rcarvall>
Here's what my .bash_profile looks like right now:
# .bash_profile
# Get the aliases and functions
if ; then
.... (2 Replies)
I want to have one .bash_profile works on multiple platform, ubuntu, debian, redhat, cygwin, osx. So how should I organize .bash_profile?
It can be multiple files in some subdir
Let me brief you:
what i want is a way to organize bash_profile across platforms so I can use one set of profiles... (2 Replies)
Hi,
Unexpectedly i entered wrong entries in .bash_profile for my user which has administrative permissions. So, i am getting errors for every command. I dont have backup file also, so any body can help me how to recover it.
Regards,
Mastan (7 Replies)
Hi All,
I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Hi,
Currently If i have created new userID then .bash_profile file is created under the new user.
Now, I would like to add one path in this file.
Please help on this .
Current file output:
# .bash_profile
# Get the aliases and functions
if ; then
. ~/.bashrc
fi
#... (4 Replies)
Hi,
happy new year.
on AIX 6.1 , for user oracle , there are two files :
bash_profile and .profile
I do not know which one is executed when login ? How to know ,
More over in both of them we have :
in .profile :
ORACLE_HOME=/appli/oracle/product/10.2.0/db_1... (5 Replies)
Hi all. when i connect as user megaguru i have a problem my .bash_profile does not working^:(
if i do:
. ./.bash_profile
all enviroment variables are in place. How can i force linux to use .bash_profile before logon process?
thanx in advance. (1 Reply)
We are more users using the oracle account, and people want to include theyr own files in .bash_profile. Like this:
while ; do
echo -n "LOGNAME is '$LOGNAME' (no sens), who are you? " >/dev/stderr
read ln
export LOGNAME=$ln
done
This works well when logging in to... (1 Reply)
Hi Guys,
I modified my .bash_profile script , and tried to change the prompt.
Following is the line of code in my .bash_profile script.
export PS1=" \W "
But I get the output as:
\W
This appears to be my prompt now.
Any idea what should be done..
Thanks! (0 Replies)
Dear experts,
I have installed Ruby in the following directory:
$ pwd
/home/ewijaya/.ruby
$ ls
bin lib share
And I have also stated the PATH in my bash_profile like this:
# .bash_profile
# Get the aliases and functions
if ; then
. ~/.bashrc (1 Reply)