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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
09-02-2013, 12:56 PM
|
#1
|
LQ Newbie
Registered: Aug 2013
Posts: 3
Rep:
|
Any shell scripts repository examples?
Hi all,
Is there any web site with common SysAdmin shell scripts repository examples?
I remember there was one with many categorized (file system/networking/processes, etc.) shell scripts but I can't find it anymore.
Regards.
|
|
|
09-02-2013, 01:26 PM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,145
|
Quote:
Originally Posted by RigsJuarez
Hi all,
Is there any web site with common SysAdmin shell scripts repository examples?
I remember there was one with many categorized (file system/networking/processes, etc.) shell scripts but I can't find it anymore.
Regards.
|
There are some sites like Hotscripts, and many more you can find with a Google search.
|
|
|
09-02-2013, 11:06 PM
|
#3
|
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187
|
I keep my common shell scripts in /usr/share/bash, and use this script to "include" the ones I want:
Code:
$ cat /usr/share/bash/include
#!/bin/bash
# Define the function to include all the programs listed in "$*" from /usr/share/bash
#
# Usage: include function1 {function2 ...}
#
# Note: This function assumes that any function to be included may be an executable script
# and searches $PATH for any match before looking in the location array entries.
#
# Define the include function if it's not already defined
if [ "$(type -t include)" != "function" ]
then
include ()
{
local d f abort loc found
local -a locations
# This is the array naming the locations to be searched
locations=("/usr/share/bash" "${HOME}/Scripts/Bash")
abort=0
for f in "$@"
do
loc=$(type -P "${f}")
if [ -z "${loc}" ]
then
found=0
for d in "${locations[@]}"
do
if [ -f "${d}/${f}" ]
then
. "${d}/${f}"
found=1
break
fi
done
if [[ ${found} == 0 ]]
then
echo Error: The bash include file \"${f}"\" could not be found." > /dev/stderr
abort=$((++abort))
fi
else
. "${loc}"
fi
done
[ ${abort} -gt 0 ] && exit ${abort}
}
fi
Here's an example of how I use it:
Code:
# Load the local function definitions
. /usr/share/bash/include
include define_colors \
sucmd \
connect_using_nmcli_to \
vg_activate \
mount_noauto \
mount_cifs \
mount_iso
|
|
1 members found this post helpful.
|
05-13-2017, 05:34 PM
|
#4
|
LQ Newbie
Registered: May 2017
Posts: 5
Rep:
|
Linux-shell-base
For a resource of solutions to low-level shell scripting problems in Linux, see linux-shell-base. It provides solutions for multiple aspects of the Linux application layer.
Last edited by ajb57; 05-19-2017 at 01:58 PM.
|
|
|
05-19-2017, 12:28 PM
|
#5
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,892
|
|
|
|
All times are GMT -5. The time now is 12:15 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|