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 03-31-2015, 04:24 PM   #1
sigint-ninja
Member
 
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 485

Rep: Reputation: 29
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
 
Old 03-31-2015, 04:39 PM   #2
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 824

Rep: Reputation: 237Reputation: 237Reputation: 237
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.
Old 03-31-2015, 06:19 PM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,436

Rep: Reputation: 611Reputation: 611Reputation: 611Reputation: 611Reputation: 611Reputation: 611
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
 
Old 04-01-2015, 12:58 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,327

Rep: Reputation: 225Reputation: 225Reputation: 225
check out this link:

http://mywiki.wooledge.org/FullBashGuide

or just trawl the web like searching Google "Bash Beginners Guide"
 
Old 04-01-2015, 06:42 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,712
Blog Entries: 12

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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:
  1. Regular Expressions
  2. awk or gawk
  3. sed

Last edited by rtmistler; 04-01-2015 at 06:43 AM.
 
Old 04-01-2015, 02:19 PM   #6
sigint-ninja
Member
 
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 485

Original Poster
Rep: Reputation: 29
thanks all
 
Old 05-19-2017, 12:19 PM   #7
ajb57
LQ Newbie
 
Registered: May 2017
Posts: 4

Rep: Reputation: Disabled
Arrow 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.
 
Old 05-19-2017, 12:28 PM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,712
Blog Entries: 12

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
@ajb57 welcome to LQ.

Stop resurrecting very old questions and posting your same information and link.

If you wish to self-promote some code you may do so with a single new thread.

http://www.linuxquestions.org/questi...ts-4175538361/
http://www.linuxquestions.org/questi...es-4175509965/
http://www.linuxquestions.org/questi...es-4175420036/
http://www.linuxquestions.org/questi...es-4175475605/
 
Old 05-19-2017, 05:40 PM   #9
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth( I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 3,645
Blog Entries: 2

Rep: Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110Reputation: 1110
Code:
irb
https://pine.fm/LearnToProgram/chap_01.html
 
  


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
can u provide to learn some useful links for basic shell scripts with examples sekhar.hai Linux - Newbie 6 05-19-2017 12:28 PM
Any shell scripts repository examples? RigsJuarez Linux - Newbie 4 05-19-2017 12:28 PM
Good Code Examples JMJ_coder Programming 10 09-17-2007 07:05 PM
Good Ajax Code Examples Neko_D Programming 5 04-09-2007 03:17 PM
Anyone know where I could get some good examples of sendmail files? WorldBuilder Linux - Networking 1 05-14-2003 04:12 AM

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

All times are GMT -5. The time now is 07:27 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration