less is part of the GNU project and is free software. It is a program similar to more, but which allows backward movement in the file as well as forward movement. Also, less does not have to read the entire input file before starting, so with large input files it starts up faster than text editors like vi. Less uses termcap (or terminfo on some systems), so it can run on a variety of terminals.
In second part of AWK tricks and hacks will be described how to print lines between two patterns, how to add character, word or anything else on beginning and at the end of line.
Rsync is free file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. Rsync finds files that need to be transferred using a quick check that have changed in size or in last-modified time. Any changes in the other preserved attributes (as requested by options) are made on the destination file directly when the quick check indicates that the file’s data does not need to be updated.
For more professional like scripting is nice to use options, where we can do different work with one script just using it. In this article I will show you, how to write script, where we can switch what to do using options -h for help, or -e for echoing “hello world”. Of course, this is just example and we can use it for more complex work than just hello world :).
Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). Screen is usually used when we do work which cannot be terminated. For example when is system patched remotely on unstable network, all work can be destroyed during network failure, in this case, screen is very good solution. Screen session will be running, even my ssh connection will be terminated by network. When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would.
During scripting in environment, where is used more UNIX/Linux platform we must adapt our scripts for slight differences between those platforms. Here is little example how we can do it and few examples how is script working at different platforms.
This topic will show you, how easy we can setup ssh between two systems that we will not need to write password anymore during log in to system. In this case we have user testuser and two servers system1 and system2.
In first step we need to generate ssh key pair, for which we use command ssh-keygen. Note, command for generating ssh keys will ask us for passphrase, this could be empty.
During programming sometimes we need make script more interactive. There is little example how we can do such interactive script which is asking simple question about continuing and we will quit program by pressing “c” char. I hope this example is understandable for everyone.
Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). in this post I will show you how easy we can replace text, marge two line into one and strip multiple spaces to one.
1. at first basic check by one command
In output we can see utilization of memory and and swap. we can change output with -b bytes -k kilobytes instead of -m megabytes. Option -t is used for showing memory with swap (-t as total).
# free -tm total used free shared buffers cached Mem: 128393 82606 45787 0 9873 40943 -/+ buffers/cache: 31789 96604 Swap: 34815 4773 30042 Total: 163209 87379 75830 #
If we are not satisfied with this output we can be more detailed by next scripts.