Tag: Shell
Bash Shell Scripting Tutorial
by Samet Kilictas on Apr.30, 2010, under General, HowTo, Linux
Basics
This tutorial assumes that you already know how to log in to your UNIX machine, bring up the bash shell, and run basic commands such as ls and cat. Getting to this point is fairly easy, but unfortunately this is the level that most users stay at indefinitely. This tutorial is intended to help you start to learn the more advanced features of using a shell, and specifically bash, one of the most powerful shells available.
Please note that most of the command themselves are not explained; you can examine their functionality yourself by either reading their man page, or just experimenting with them to see what they do.
Redirection
Normally programs take input from our keyboard, and display the output to our screens. However, these are just the defaults – UNIX has the ability to redirect the input (commonly referred to as stdin, short for standard input) and output (commonly referred to as stdout, short for standard output).
Here is a simple example: the cat command displays the contents of a file to the screen. But we can redirect those contents to a file using the redirection operator ‘>’, like so:
$ cat myfile.txt This is the contents of the file myfile.txt $ cat myfile.txt > newfile.txt $ cat newfile.txt This is the contents of the file myfile.txt $
In effect, we’ve made cat do the same thing as cp, by redirecting the output from the screen to a file. This isn’t terribly useful, but consider another, similar, scenario: cat can take multiple arguments, and it will display the files one after the other. This can be used to append one file onto another and create a new, combined file.
$ cat file1.txt The quick brown fox... $ cat file2.txt ...jumped over the lazy dog. $ cat file1.txt file2.txt > combined.txt $ cat combined.txt The quick brown fox... ...jumped over the lazy dog.
Neat, eh?
We can also redirect the input, so that a program takes the contents of a file as if it were typed at your keyboard. cat doesn’t take any input, so let’s use bc, a command line calculator. Normally, you run the program, and it lets you type in calculations such as “2+2″, and then displays the result. But if you have a file which already contains the calculations, you can send it straight to bc – faster and more powerful than cutting-and-pasting the text in with your mouse.
$ cat calc.txt 2+2 $ bc < calc.txt 4 $
A final note: you can use two output redirect symbols together – >> – to indicate that you want to append the file, not overwrite it. Hence:
$ cat file1.txt Contents of file1. $ cat file2.txt Contents of file2.txt. $ cat file2.txt >> file1.txt $ cat file1.txt Contents of file1. Contents of file2.txt. $
Free Shell Accounts
by Samet Kilictas on Aug.21, 2009, under General
Here is a tiny list of free shell account services. I should remember them when i need it.
- http://www.bylur.net/free/
- http://www.red-pill.eu/freeunix.shtml *
- http://www.rootshell.be/
Unix Toolbox
by Samet Kilictas on May.18, 2008, under General, Linux
Bloguma daha yeni yazı ekledim ama az önce gezerken buldum bu dökümanı çok güzel.. okuyorum şu an dayanamadım bitirene kadar hemen burdanda duyurmak istedim.
This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations, however the reader is supposed to know what s/he is doing.
Buyrun burdan inceleyebilirsiniz. UnixToolbox
Thanks for dropping by! Feel free to join the discussion by leaving comments, and stay updated by subscribing to the 