Tag: bash

Link: Bash One-Liners Explained, Part I: Working with files

I love being super fast in the shell so I decided to do a new article series called Bash One-Liners Explained. It’s going to be similar to my other article series – Awk One-Liners Explained, Sed One-Liners Explained, and Perl One-Liners Explained. After I’m done with this bash series, I’ll release an e-book by the same title, just as I did with awk, sed, and perl series. The e-book will be available as a pdf and in mobile formats (mobi and epub). I’ll also be releasing bash1line.txt, similar to perl1line.txt that I made for the perl series.

In this series I’ll use the best bash practices, various bash idioms and tricks. I want to illustrate how to get various tasks done with just bash built-in commands and bash programming language constructs.

Also see my other articles about working fast in bash:

Full article here:
Bash One-Liners Explained, Part I: Working with files (Browserling)

Links: Bash by Example, Parts 1-3

You might wonder why you ought to learn Bash programming. Well, here are a couple of compelling reasons:

You’re already running it 
If you check, you’ll probably find that you are running bash right now. Even if you changed your default shell, bash is probably still running somewhere on your system, because it’s the standard Linux shell and is used for a variety of purposes. Because bash is already running, any additional bash scripts that you run are inherently memory-efficient because they share memory with any already-running bash processes. Why load a 500K interpreter if you already are running something that will do the job, and do it well?
You’re already using it
Not only are you already running bash, but you’re actually interacting with bash on a daily basis. It’s always there, so it makes sense to learn how to use it to its fullest potential. Doing so will make your bash experience more fun and productive. But why should you learn bash programming? Easy, because you already think in terms of running commands, CPing files, and piping and redirecting output. Shouldn’t you learn a language that allows you to use and build upon these powerful time-saving constructs you already know how to use? Command shells unlock the potential of a UNIX system, and bash is the Linux shell. It’s the high-level glue between you and the machine. Grow in your knowledge of bash, and you’ll automatically increase your productivity under Linux and UNIX — it’s that simple.

Full articles here (source: funtoo linux):
Bash by Example, Part 1 – Fundamental programming in the Bourne-again shell
Bash by Example, Part 2 – More bash programming fundamentals
Bash by Example, Part 3 – Exploring the ebuild system

Link: How to set the PATH variable in Bash

So, how do you set the PATH variable in Bash?

That’s a very simple task, which should take less than a minute to complete. However, for the benefit of those not familiar with the Bash shell or the PATH variable, let’s start with a very brief introduction.

Full article here:
How to set the PATH variable in Bash (LinuxBSDos.com)

Link: Alien’s Bash Tutorial

First you probably need to read a UNIX command bible to really understand this tutorial, but I will try to make it as clear as possible, there is about 100-150 UNIX commands explained later in this tutorial.

You are to have some UNIX experience before starting on this tutorial, so if you feel that you have UNIX/Linux experience feel free to start to learn here.

What I included here is general shell scripting, most common other things and some UNIX commands.

Full article here:
Alien’s Bash Tutorial (subsignal.org)

Link: 15 Useful Bash Shell Built-in Commands (With Examples)

Bash has several commands that comes with the shell (i.e built inside the bash shell).

When you execute a built-in command, bash shell executes it immediately, without invoking any other program.

Bash shell built-in commands are faster than external commands, because external commands usually fork a process to execute it.

In this article let us review some useful bash shell builtins with examples.

Full article here:
15 Useful Bash Shell Built-in Commands (With Examples) (The Geek Stuff)

Link: Tutorial: Customizing Your Bash Prompt

In this tutorial I will show you how you can change the look and behavior of the prompt to show more details or use a different coloring style. I will explain how to try all these examples and how to make changes permanently by adding them inside the Bash configuration file. Please note that this stuff is Bash-specific and it won’t work in other shells.

Full article here:
TuxArena | Tutorial: Customizing Your Bash Prompt (TuxArena)

RELATED: Some of you might prefer to run a program that customizes the bash prompt for you. For you there’s bash-prompt-customizer-cli at GitHub.

Link: Basic Linux Shell Scripting Language : ‘While’ Loops

In the previous article entitled “Basic Linux Shell Scripting Language : Introduction to ‘For’ Loops“, we have observed how a loop works. Loop is nothing but a control flow statement which executes a block of commands repeatedly till certain condition stays true, once the condition becomes false, the loop is terminated.

In this article, I will explain Basic syntax of ‘While’ loop along with some examples of ‘While’ loop usage. If you are new to Shell Scripting, I recommend that, you should read my article – Getting Started – Linux Shell Scripting Language.

One of the things we found interesting in this article is that it shows how to use an infinite ‘while’ loop that can only be broken out of by some specific event or condition. Very basic stuff, but something that can come in quite handy in certain situations.

Full article here:
Basic Linux Shell Scripting Language : ‘While’ Loops (Your Own Linux..!)

Link: Basic Linux Shell Scripting Language : A Simple BASH Script to Test Your Internet Connectivity

Most of the users all over the world make use of Google’s Index Page to check whether their Internet connection is working or not.  Many times it is required to check periodically whether the server you are running is connected to internet or not. It is very cumbersome to open the web page every time you wish to check the connection. As an alternative, it definitely makes sense to run some scripts in the background periodically scheduling them using cron.

The bash script that can be used for this purpose is given below:

Full areticle here:
Basic Linux Shell Scripting Language : A Simple BASH Script to Test Your Internet Connectivity (Your Own Linux..!)
More interesting Linux tutorials and articles at this site

Article series: CommandLineFu, BASH, AWK, Perl, SED One-Liners Explained

We must confess that we are not as fond of the Linux command line as some Linux users — we’ll take a good GUI, and a mouse over a keyboard any time we can. But for those that love working at the Linux command prompt (and that probably don’t make nearly as many typos as we do), we thought you might appreciate this series from the catonmat blog:

Or perhaps you’d prefer this series:

Or maybe you’d like to see one-liners covering Awk, Sed, or Perl:

 

 

Author Peteris Krumins used these articles as the starting points for his e-books. In addition to the e-books listed there, it appears that he has authored this paperback edition that can be purchased from Amazon (this is an affiliate link, so if you buy it from here we’ll get a small commission):

Perl One-Liners: 130 Programs That Get Things Done

Featured Article:

Recent Posts

Recent Comments

Archives

Categories

Meta

GiottoPress by Enrique Chavez

%d bloggers like this: