LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-30-2005, 11:42 PM   #1
alchem
LQ Newbie
 
Registered: Aug 2005
Location: New York
Posts: 12

Rep: Reputation: 0
read scripts


Someone mentioned to me about making shell scripts and I wanted to read the ones on my distro (RH9).

As i attempt to shed some newbie skin i fin i'm typing find / -name ____ often and i'd like to write a script to speed up my learning while indulging my slackard ways.

Thanks
 
Old 08-31-2005, 05:45 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Ruhr Area, Germany
Distribution: Slackware64 14.0
Posts: 1,517

Rep: Reputation: 90
I think it would be easier to set an alias for this task (man alias). For writing bash scripts look at http://www.tldp.org/guides.html -- there is a guide called "Bash Guide for Beginners".
 
Old 08-31-2005, 10:41 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
Other suggestions for reading system shell scripts.

A really laudable endeavor reading the system shell scripts.

Some other suggestions:
  • locate
  • Cruise /etc -- I like to use mc (Midnight Commander) for that:
    Code:
    mc /etc /etc
  • For a list of shell scripts in /etc:
    Code:
    # grep -RE '^#![[:space:]]*/bin/(ba)?sh' /etc/*   \
      |awk -F: '{print $1}'|less -S#20
  • To view them all in succession:
    Code:
    # less `grep -RE '^#![[:space:]]*/bin/(ba)?sh' /etc/* \
      |awk -F: '{print $1}'`
Notes
  • The '#' is to remind you to run these as root -- fewer errors & more access
  • Ignore all ":grep: ... No such file or directory" lines, they are going to stderr
  • RTfM on the things you don't understand here, it's a good opportunity to learn. less, grep, & awk are very useful tools, & I have deliberately not explained the options I used. (More chance for you to learn.)
  • Keep a good bash reference handy as you read the scripts.
  • If you want to look at other directories, change '/etc/*'.
  • EDIT: Broke long "Code" lines w/ '\\' to minimize horizontal scrolling. Be sure to re-assemble properly.



Last edited by archtoad6; 08-31-2005 at 10:46 AM.
 
Old 08-31-2005, 11:22 AM   #4
alchem
LQ Newbie
 
Registered: Aug 2005
Location: New York
Posts: 12

Original Poster
Rep: Reputation: 0
archtoad6,
thanks! i wont be able to try until later....
i tried to locate the script run from the 'more' command by using find / -name more, hoping this would lead me to the actual script and when i tried to open the 'script' with vi, as determined by the results of find, i got junk printed.
i guess the commands you posted somehow make the scripts into human language as opposed to the machine language these files are in.
 
Old 08-31-2005, 11:42 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 231Reputation: 231Reputation: 231
Scripts by definition are text files. You probably have been trying to look at binaries too.

BTW, after you are done w/ /etc/*, consider /bin/* & /sbin/*; they are mostly binaries, but there are a few scripts.

BTW2, the extension '.sh' is supposed to indicate a shell script, but is not mandatory. In *nix, file extensions are advisory only.
 
  


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
Mounted read-write Fat32 partition suddenly becomes read-only?? hohead Linux - General 8 04-05-2007 12:17 PM
VPN: Debian Scripts -> Mandriva 2006 Scripts Undefined Mandriva 0 11-30-2005 12:10 PM
Example share in smb.conf doesn't work - read/write vs read only kleptophobiac Linux - Networking 0 09-01-2004 07:14 PM
Need help running scripts from scripts sdouble Linux - Newbie 3 05-31-2004 12:56 PM
kernel panic unable to mount root (yes ive read/read other posts) dmx9595 Linux - General 4 01-17-2004 05:07 AM


All times are GMT -5. The time now is 11:31 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration