• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Linux, using 'exit' in a script

I want to use exit in a script in RHEL 6.x

Something like:

su - user1

Open in new window

This will restart my .profile

I know there are other ways of doing this, but I want to concentrate on how to use exit in a script

How can I do this ?

Thanks in advance
Los Angeles1
Los Angeles1
3 Solutions
usage ()
echo "nil arguments detected"
exit 1 #exit shell script

if [ $# -eq 0 ];

echo "still here!"
Sorry not understanding your concerns.  Could you elaborate a little more.

You want to exit out of a user and then su - user1 just to reload your profile?

Why don't you simply reload it?

. .profile

Notice the first dot.

In bash your profile file is .bash_profile

So you need to do
. .bash_profile
Gerwin Jansen, EE MVETopic Advisor Commented:
I usually do . ~/.bash_profile - this works as long as your HOME variable is set correctly. Basically same as farzanj is suggesting.

(admin note)
If you want experts to help you, please add some explanation as to why you want to use 'exit' or experts will have to guess and make a lot of suggestions that are of no use to you. Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now