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.
|
|
03-31-2015, 04:24 PM
|
#1
|
Member
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 508
Rep:
|
good examples of bash scripts
hi guys,
i know what bash scripts are
how to make them
and how to run them...
i have written some basic scripts that
show what users are logged on
how much free disk space there is etc
backup folders with rsync
also made a menu that let me select which host i wanted
to rdp into.
could somebody post here or point to a web site that has good examples of well used bash scripts on a production server...to see what / or try to see what exactly is going on...
would really appreciate any help
|
|
|
03-31-2015, 04:39 PM
|
#2
|
Senior Member
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 1,019
|
You can typically found tons of reasonably well-written scripts on your own system...
Try e.g. (as root)
Code:
grep -lr '#!/bin/sh' /etc
to find shell scripts
and
Code:
grep -lr '#!/bin/bash' /etc
to find bash scripts.
Instead of etc other directories (e.g. usr) also make sense. It obviously depends a bit on your distro
Last edited by joe_2000; 03-31-2015 at 04:39 PM.
Reason: fixed broken code tag
|
|
2 members found this post helpful.
|
03-31-2015, 06:19 PM
|
#3
|
Senior Member
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,190
|
http://bashscripts.org/forum/
also grab a copy of the advanced bash scripting guide, it may be in your distros repo if not google it
|
|
|
04-01-2015, 06:42 AM
|
#5
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,894
|
My $0.02 in BASH are in my signature links, the last line of it actually. One is a blog entry with some samples but really debug suggestions for general BASH programming. Also are links for the BASH guides.
You can just Google for "sample BASH scripts" and even be specific like "BASH script find files example" stuff like that.
The link provided by Keith Hedger is very good.
And also if you check out the LQ forums, specifically the Software and Programming forums you'll find a lot of BASH script questions with very helpful answers.
A few things to learn in addition to just scripting would be: - Regular Expressions
- awk or gawk
- sed
Last edited by rtmistler; 04-01-2015 at 06:43 AM.
|
|
|
04-01-2015, 02:19 PM
|
#6
|
Member
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 508
Original Poster
Rep:
|
thanks all
|
|
|
05-19-2017, 12:19 PM
|
#7
|
LQ Newbie
Registered: May 2017
Posts: 5
Rep:
|
Linux-shell-base
Good resources to use as examples are those with UNIX-centric solutions that solve low-level problems. Please see linux-shell-base as it was created for such solutions. Here is a list of some of the scripts it contains:
- Run a command in the background (module).
- Get the ID a window by name, class, PID, etc.
- Get the ID, name, class, PID, etc. of the active window.
- Return a file for a command by locating or recursively searching for it (module).
- Check if a WLAN device is soft blocked.
- Run a command in the terminal from outside of it (keybind utility).
- Run a countdown timer in the terminal.
- Bash utility functions (array, string, http, etc.).
- Get contact info from an Android device.
- Send an sms using an Android device.
Last edited by ajb57; 05-19-2017 at 12:50 PM.
|
|
|
05-19-2017, 12:28 PM
|
#8
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,894
|
|
|
|
05-19-2017, 05:40 PM
|
#9
|
Senior Member
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
|
|
|
|
All times are GMT -5. The time now is 05:43 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
|
|