LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-22-2018, 11:59 PM   #1
anon297
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Rep: Reputation: Disabled
my own script related question!


Dear mentors!
I posted a question on LFS forum and this is slightly different one.

I know how to make my own script(for easy tasks only) and use it with './something.sh', but if I want to use it as something like coreutils($cp, $ls like that), how can I achieve that?

I mean, If I want to use my own function with just
$my_own_1 -e 'blah blah'

how can I do that? Do I have to make my script in '/bin' directory? or export my function? or alias my function with execute script?

Thanks for your reading and your help!
 
Old 04-23-2018, 12:11 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
you want to call the script without having to type out its path?
then it should be stored in your PATH!
Code:
echo $PATH
if "$HOME/bin" is already in it, that's where your script should go. symlink or copy, doesn't matter (in principle).
if not, do this as a normal user:
Code:
mkdir ~/bin
and add this line to whatever file your login shell parses first:
Code:
PATH="$HOME/bin${PATH+:}${PATH}"
(it's ~/.bash_profile on my system, but this varies!)
 
1 members found this post helpful.
Old 04-23-2018, 12:14 AM   #3
anon297
Member
 
Registered: Feb 2018
Location: Seoul,South Korea
Distribution: Debian
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
you want to call the script without having to type out its path?
then it should be stored in your PATH!
Code:
echo $PATH
if "$HOME/bin" is already in it, that's where your script should go. symlink or copy, doesn't matter (in principle).
if not, do this as a normal user:
Code:
mkdir ~/bin
and add this line to whatever file your login shell parses first:
Code:
PATH="$HOME/bin${PATH+:}${PATH}"
(it's ~/.bash_profile on my system, but this varies!)
Awesome!!! Thanks really helped me a lot!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] My own bash script related question. anon297 Linux From Scratch 5 04-24-2018 12:44 AM
issue related to shell script manglesh.vyas Linux - Newbie 2 12-07-2010 05:39 PM
shell script related to square of number question studywell09 Programming 6 02-07-2010 02:32 PM
Need a script help related to Kernel sharp859 Programming 3 04-17-2009 12:00 PM
shell script (bind related) OTIM Programming 6 07-10-2008 04:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration