Not quite. To represent the situation schematically the issue looks smth like this:
1.
normally is executed every time I open new Terminal window or start a new Terminal session (by typing the command
in Terminal Preferences where you can customize what command for Terminal to execute on starting a session). I can't tell the exact moment it disappears but MOST of the time (except when it's being deleted) during my interactive session I'm able to use commands put in there successfully.
We understand that. But, when you start a new terminal session, you don't need to type the command ./.bashrc if bash is the shell running in that terminal session. When bash is invoked as a login shell, it runs .bashrc in your home directory as part of its initialization steps.
Quote:
2. It also sits in its location immutably undergoing numerous shutdowns, reboots and so on.
We understand that.
Quote:
3. At some point coinciding with some reboot (or with turning my Mac on) on Terminal trying to execute
it fails because it tells
You are assuming at least two things here, neither of which are backed up by what you have told us:
The file $HOME/.bashrc is removed during a reboot. Nothing you have shown us tells us that $HOME/.bashrc was not removed 1 second after the last terminal session you started. It could have been removed any time after you started the last terminal session up until the next time you rebooted; not just as a side effect of rebooting.
The files ./.bashrc and $HOME/.bashrc are the same file. If, at any point after you start a terminal session you issue a cd directory command, the command . ./bashrc would then be expected to fail in that terminal session unless you have issued another cd command that moves you back to your home directory.
Quote:
when I start Terminal session/open a new Terminal window. Executing the command
reveals it's gone forever.
BTW, it was the second time I detected such misbehavior. The first time I had manually recreate the file together with all configurations I laboriously put into it.
OK. So, first you told us the file disappears predictability (sic) after an unknown number of reboots. I asked what happens that allows you to predict when it will disappear. You have not answered that question. And, now you tell us, that instead of the file disappearing predictably after some number of reboots, it has happened two times.
That file does not disappear as a side effect of rebooting unless you have modified a system or personal file that is executed when your system reboots that causes that file to be removed. It is MUCH MORE likely that you are doing something while you are logged in that is removing that file and you just don't notice it until you reboot after you have removed it. That is why it is important to know how you can predict when the file will disappear. If you can predict that the file won't be there the next time you reboot, it is probably because you have just done something that removed the file.
If you have issued a command to remove your own file, we can make it a little more likely that a warning will be printed before it is removed; but there is nothing we can do to keep you from removing your own file if you tell your shell to remove your file. You make it more difficult in some cases by making the file read-only after you recreate the file with the contents you want. The command:
will do that. If you then try to remove the file using:
it will ask for confirmation before removing your file. But, if you use the command:
that command will happily remove your file exactly as you requested with no warning.
Of course, you would not have to actually type in one of the above commands literally to remove your file. It could also be done with an unlink command or library call, a rename command or library call, or a mv command (but, note that with rename or mv, the file's contents may still be present in a file with a different name instead of actually gone).
If you run the command:
frequently, it will eventually report that the file is not found. And, if you can identify what you were doing before it disappeared, we'll have a better chance of tracking down what you are doing that is removing the file.
I search the web and found the following statements
.....
The /etc/profile file is a system wide initialization script which is run at login time for each user, while .profile is the users own login initialization. The .bashrc file is an initialization file run by each interactive invocation... (1 Reply)
Hello,
I got this question which tells me to customize my login script. Some people in the forums suggested to modify the .profile file in my home directory. I did so, but none of my customizations show up when I open the terminal after.
So, I tried to modify other files in my home directory,... (1 Reply)
hi i am using cygwin and would like to modify my .bashrc file. How can search to find where it is? I have looked at multiple bashrc file in /etc but none of them seemed to work..thanks (12 Replies)
Hi experts,
I am using bash shell and I cant find any .bashrc file in my home dir. Can anybody please help me out here....
If .bashrc file is not there, from where my shell config operates? Also I want to set my prompt like...
$
Please advice. (5 Replies)
I want to write a script that deletes files inside the dir. However, the script
should also allow the user to confirm by pressing (d) key before deleting files..
#!/bin/bash
for file in $1/*
do
size='ls -l $file | cut -f 5 -d " "'
name='ls -l $file | cut -f 9 -d " "'
... (1 Reply)
Hi
I am using sed command to make SCORE=somevalue to SCORE=blank in a file.
Please see the attached lastline.txt file. After executing the below command on the file, it removes the last line.
cat lastline.txt | sed 's/SCORE=.*$/SCORE=/g' > newfile.txt
Why does sed command remove the... (3 Replies)
I am using Tbird as it came with Slackware 13.37 and everytime I send something I get a message 1 or 2 drafts deleted. Should it be doing that? If not has this been reported ? How can I find out if it was reported? I have no drafts to delete. (2 Replies)
i am trying to remove a directory using rm -rf command but its not getting removed.. it doesnt throw any error also.. i am logging as the owner of the dir and removing it but still no luck.. i am able remove a file but not a directory.
i am using solaris 10 (12 Replies)
Hello All,
I was wondering if there is a way to execute a command in my ".bashrc" file based on how I logged into the PC?
I was thinking maybe there is a way to check how the user (*myself) logged in, maybe somehow with the who command along with something else, but I'm not sure... I know I... (7 Replies)