LinuxQuestions.org
Register a domain and help support LQ
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 11-05-2008, 09:33 AM   #1
culin
Member
 
Registered: Sep 2006
Distribution: Fedora Core 10
Posts: 254

Rep: Reputation: 32
Using Shell scripting


Hi all,
Can anyone tell me Where shell scripting is used ? or say any general scripting language for that matter !!! i am feeling that i am not able find the exact usefulness and necessity of shell scripting.. I just went through one of the Basic shell scripting guides, but i could not get satisfied with myself that where can i use all these things ?
So Please suggest me some practical areas where shell scripting or any scripting is used ? How it is helpful ? and also give me some mini projects on Shell scripting so that i can make use of what i have learnt...

Thanks and Regards
Naren.
 
Old 11-05-2008, 09:42 AM   #2
ceantuco
Member
 
Registered: Mar 2008
Location: New Jersey
Distribution: CentOS, Debian, Kali
Posts: 577

Rep: Reputation: 37
Hi Culin! on this website you will find what you are asking for http://freeos.com/guides/lsst/
Personally I use shell scripting for a couple things, I'm just learning it but it is awesome...
Good luck!
 
Old 11-05-2008, 01:20 PM   #3
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285
Well, lets see, here are some of the things I wrote bash scripts to do:

* CD/DVD burning script, can burn iso or directory, identifies the type of disk in the drive, checks sizes to see if it fits, burns it.
* generate md5sums of all files in current directory recursively
* install the kernel and check to make sure things are setup properly so it will boot
* record current processes, kill processes that are not in the record
* fixes all names in current directory to be lower case and without spaces
* set system time in a more friendly way
* wrapper for rm to prevent deleting of top level directories and 1 level down
* package management (obsoleted)

But, I use shell scripting more than for just making scripts, it comes in handy when I need to automate things like downloads, renames, etc.

Last edited by H_TeXMeX_H; 11-05-2008 at 01:22 PM.
 
Old 11-05-2008, 01:55 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
A couple of random ideas for things I've done in the past that you might find interesting and/or challenging.
  • An universal command line unpacker, which doesn't care about the type of archive. It parses the file and uses the correct program to extract it.
  • A script to find .lnk windows files under a given dir, and convert then to linux symlinks.

Besides that, I use bash scripting intensively in my daily work when handling batch operations from command line. I use test cases and loops intensively every five minutes to do one thing or another.

Last edited by i92guboj; 11-05-2008 at 01:57 PM.
 
Old 11-05-2008, 03:00 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
I installed Cygwin/X at work so I could use bash and the coreutils. For highly repetitive things, you can be do things easily in the shell that would be too difficult in the GUI. I make catalogs of backup DVDs from the ls -l listings and using cat, sort, cut, sed, enscript and ps2pdf, produce pdf catalogs. Using just a handful of handy utilities, piped together produces something I can't in the GUI. I also need to take a list of spots to delete, find which ones are in a device's inventory and delete them. Doing this graphically would take much too long using the "file manager" for these devices. Extracting the spots to delete from an inventory list (of thousands) is much easier done in the shell. There are 15-25 devices per site, and the web based tool we have that should do it automatically doesn't work.

If you need to do perform an operation on certain files that are contained in several directories and subdirectories, the graphical selection process (Object-Action) becomes too difficult or impossible.

Sometimes using the GUI makes more sense. I wouldn't want to try removing red-eye from a photo in the shell. Putting a watermark on a photo using the Gimp is easier to do then using one of the ImageMagick programs. But if you want to do the same for hundreds of pictures, automating the process in a script would be easier.
 
Old 11-17-2008, 04:58 AM   #6
culin
Member
 
Registered: Sep 2006
Distribution: Fedora Core 10
Posts: 254

Original Poster
Rep: Reputation: 32
wooow.. thanks for all replies.. and sorry for the late reply...i was out of station..
yes surely i will also do some mini projects on shell scripting and then will post back for queries and problems...
 
Old 11-17-2008, 08:06 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Shell scripting is a programming language.
Programming languages are used to write computer applications---ie code that does something useful (to someone).

So maybe the question is "Why would anyone need computer applications?" (There are times where I really wonder......)
 
Old 11-17-2008, 08:30 AM   #8
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Quote:
Originally Posted by pixellany View Post
Shell scripting is a programming language.
Programming languages are used to write computer applications---ie code that does something useful (to someone).

So maybe the question is "Why would anyone need computer applications?" (There are times where I really wonder......)
To be able to copypaste homework from wikis and Encarta

Another issue is that the playstation doesn't do all that alt+tab magic, that is so necessary when parents or bosses are around, with all the games and porn and stuff.

Besides jokes, what the OP should ask to himself is if he has a problem to solve. Programming languages are created to program applications that solve a given problem. If you haven't got any problem so solve, then trying to solve "it" has no sense. And that's the impression I got from this thread.
 
Old 11-17-2008, 10:02 AM   #9
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285Reputation: 1285
Quote:
Originally Posted by i92guboj View Post
Another issue is that the playstation doesn't do all that alt+tab magic, that is so necessary when parents or bosses are around, with all the games and porn and stuff.
That's why you have 2 workspaces one labeled "work" and one labeled "play" and a hotkey to switch between
 
Old 11-17-2008, 10:11 AM   #10
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by culin View Post
Hi all,
Can anyone tell me Where shell scripting is used ? or say any general scripting language for that matter !!! i am feeling that i am not able find the exact usefulness and necessity of shell scripting.. I just went through one of the Basic shell scripting guides, but i could not get satisfied with myself that where can i use all these things ?
So Please suggest me some practical areas where shell scripting or any scripting is used ? How it is helpful ? and also give me some mini projects on Shell scripting so that i can make use of what i have learnt...

Thanks and Regards
Naren.
Simply put in the Administrators world: Scripting is used when you'll be doing the same task more than once. If you have to do it again, script it to automate your work.

Learn to be a lazy administrator and always do your tasks once while letting you're scripts do the rest of your work. Automation with scripts gives you more time to surf the net and look at others emails.
 
Old 11-17-2008, 12:31 PM   #11
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Quote:
Originally Posted by H_TeXMeX_H View Post
That's why you have 2 workspaces one labeled "work" and one labeled "play" and a hotkey to switch between
Yup. I am a big fan of worspaces. I am an xmonad user which is amazing at managing them, including full xinerama support, which 99% of the wm's around lack (even if they claim to have such support).

I just mentioned alt+tab because it seems to be more famous
 
Old 11-18-2008, 12:20 PM   #12
ceantuco
Member
 
Registered: Mar 2008
Location: New Jersey
Distribution: CentOS, Debian, Kali
Posts: 577

Rep: Reputation: 37
I recently created a script with a list of all kinds of music I have on my pc so it asks me what kind of music I would like to listen to? Of course there is a given list which I select the type let's say ROCK or OLDIES, etc and AMAROK will load my music! back then when I used W$ndows I had to go to each folder and right click the mouse to select all files then select the play option and if my machine didn't froze I will be listening to my favorite songs in a couple minutes! if not a necessary re-start would be required!
 
  


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
LXer: Terminal functions for shell scripting with Shell Curses LXer Syndicated Linux News 0 03-27-2008 12:50 AM
SHELL scripting/ shell functions mayaabboud Linux - Newbie 6 12-26-2007 09:18 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 04:32 PM


All times are GMT -5. The time now is 12:50 AM.

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