LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Bash shell scripting Part I & Part II (http://www.linuxquestions.org/questions/linux-general-1/bash-shell-scripting-%96-part-i-and-part-ii-4175444126/)

onebuck 01-04-2013 07:11 AM

Bash shell scripting Part I & Part II
 
Hi,

Bash shell scripting – Part I;
Quote:

This tutorial is a three part series as an introduction to Bash Shell Scripting. Part I is mainly basics of shell scripting and is generic, Part II will gradually move towards some more advanced techniques and focus mostly on the bash shell and finally in Part III we will try to use all the techniques to create working program.

A basic understanding of Linux shell is required for this tutorial. Please refer to Introduction to Linux Shell and Introduction to Shell Environment to learn more about Linux shell.
Bash shell scripting – Part II;
Quote:

In the first part of this article series on shell scripting we covered basics of what shell scripting is and how we can use it like other programming languages to automate our work. Now we are going to cover some more advanced technique such as arrays, functions, networking etc which makes these shell scripts much more than just bunch of commands.
Other useful links in Links for Helpful Linux articles & books

nonamedotc 01-04-2013 08:51 AM

Aha! These are very nice tutorials. :study:

Thanks for the links. :hattip:

rootaccess 01-04-2013 12:04 PM

thanks for the links. this is exactly what i am learning right now. literally blocking everything out to learn it well.

edit: do you know of any good bash shell scripting books that are not too costly? I know I can get all this information free but I enjoy being outside and not having all the EMF's running through me, not to mention the glare of the laptops and battery drainage among other things just to read stuff. I feel more focused when I just have bash shell scripting in my hand with no access to anything else on my computer.

I came across this one which was written last January 2012, so its a year old. Is it worth it?

http://www.barnesandnoble.com/w/the-...1593273897&r=1

kooru 01-05-2013 03:18 AM

As always: thanks about links ;)

Habitual 01-06-2013 10:17 AM

Quote:

Originally Posted by rootaccess (Post 4863001)

yes.

dugan 01-09-2013 11:52 AM

Quote:

Originally Posted by rootaccess (Post 4863001)

It's available for free.

http://linuxcommand.org/tlcl.php

rootaccess 01-09-2013 01:07 PM

I have the e-book. I was implying about the physical book. Sometimes I am away or don't feel like sitting on a chair just to read. I can't buy every physical book because that'll add up.

Also was considering the bash cookbook which seems pretty in-depth. 2007 edition

Xeratul 01-09-2013 03:41 PM

Quote:

Originally Posted by onebuck (Post 4862802)

there is too a cool epub book for free somewhere, gnu, oppen source epub about bash

jmc1987 01-09-2013 04:07 PM

Nice post

Kallaste 05-31-2013 10:59 AM

Thank you, this is very nice.

Xeratul 05-31-2013 11:01 AM

Quote:

Originally Posted by BloomingNutria (Post 4962873)
Thank you, this is very nice.

Why not coding in C? It is also very simple and more powerful

onebuck 05-31-2013 11:31 AM

Member Response
 
Hi,

You can use a shell script to experiment before implementing a high level language program. Most times you will layout the problem and align task(s) requirement(s) then experiment via a simpler script using available commands.

Sometimes you won't even need to move to 'C' or other language to implement a simple task. Of course if the task is time restrictive then a program in a higher level language would/could be used.

More than one way to skin a cat! :hattip:

Kallaste 05-31-2013 12:20 PM

Quote:

Originally Posted by Xeratul (Post 4962877)
Why not coding in C? It is also very simple and more powerful

I do code in C, and I appreciate it's power. But shell scripts are very prevalent throughout the Linux ecosystem, and it is helpful to be able to understand them so you can modify them and write your own when necessary.

WHITE_POWER 05-31-2013 04:17 PM

I know most of the stuff already, but I did picked up some new things mostly in part II

Firerat 10-04-2013 08:48 AM

@EVyshnavi
your posts are way off topic

but to answer your question,
you need to do a couple of things
first find out where olsrpkt.h is , then find out what references it in code

to find the file

Code:

find . -name olsrpkt.h
to find it in code
Code:

grep -r -n olsrpkt.h *
the -n will also display the line number
Warning:
What follows is not real...
it is just an example of one way to 'fix' it
you need to use some of your own brain power to achieve results

now, let us assume you find the file in
./somedir/another/include/um-olsr/olsrpkt.h ( I made it up )
and your 'code' is
Code:

#include <olsrpkt.h>
change it to
Code:

#include <um-olsr/olsrpkt.h>
you could do that with sed
Code:

for i in "$( grep -rlz olsrpkt.h * )";do sed -i 's#<olsrpkt.h>#<um-olsr/olsrpkt.h>#' "${i}"';done
or, if just one or two, just use vim to 'jump' to the line
Code:

vim path/to/file +<lineNumber>
or use whatever editor you are comfortable with ( well, not notepad as it will 'messup' the end of lines.. )


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