Bash Articles RSS Feed
How to get a password from a shell script without echoing - solutions
Viewed 1292 times since Fri, Feb 22, 2019
#!/bin/bash # Read Password echo -n Password: read -s password echo # Run Command echo $password #!/bin/bash stty -echo printf "Password: " read PASSWORD stty echo printf "\n"   read -s -p "Password: " password $ help read read: read [-ers] [-... Read More
Bash: Read File Line By Line – While Read Line Loop
Viewed 585 times since Mon, Feb 18, 2019
The while loop is the best way to read a file line by line in Linux. If you need to read a file line by line and perform some action with each line – then you should use a while read line construction in Bash, as this is the most proper way to do the... Read More
HowTo: Clear BASH History
Viewed 519 times since Mon, Feb 18, 2019
Sometimes you don’t want to leave Bash history, because it may contain some sensitive data like passwords. This article may help you to control your Bash history file. Clear Bash history completely Type the following command to clear all your B... Read More
“Yes/No” in Bash Script – Prompt for Confirmation
Viewed 1486 times since Mon, Feb 18, 2019
Very often in bash scrips you need to ask for user input that requires a Yes or No answer. For example, you may want to put a quick “Are you sure?” prompt for confirmation before execution of some potentially dangerous part of a bash script. In this ... Read More
Bash: String Length – How To Find Out
Viewed 695 times since Mon, Feb 18, 2019
If you often create Bash scripts, you may sometimes need to get the length of a string or find out the length of a variable that stores some string. This short note shows how to find out the length of a string from the Linux command line and how to c... Read More
Linux: Repeat Command N Times – Bash FOR Loop
Viewed 589 times since Mon, Feb 18, 2019
Sometimes you might need to run some command from the Linux command line and repeat it several times. There is a simple way to write a command once and have it executed N times using Bash loop FOR. In this short note you’ll find how to execute ... Read More
30 Examples for Awk Command in Text Processing
Viewed 1633 times since Sat, Nov 24, 2018
In the previous post, we talked about sed command and we saw many examples of using it in text processing and we saw how it is good in this, but it has some limitations. Sometimes you need something powerful, giving you more control to process data. ... Read More
The Ultimate Bash Array Tutorial with 15 Examples
Viewed 745 times since Sun, Sep 30, 2018
An array is a variable containing multiple values may be of same type or of different type.  There is no maximum limit to the size of an array, nor any requirement that member variables be indexed or assigned contiguously. Array index starts with zer... Read More
O’Reilly’s CD bookshelf
Viewed 4548 times since Wed, Jun 27, 2018
https://docstore.mik.ua/orelly/bookshelfs.html   The Java Reference Library, version 1.3 The Java Enterprise CD Bookshelf, Version 1.0 The Perl CD Bookshelf, version 1.0 ... Read More
Epoch & Unix Timestamp Conversion Tools
Viewed 13747 times since Fri, Jun 22, 2018
The current Unix epoch time is  1529656113   Convert epoch to human readable date and vice versa  [batch convert timestamps to human dates] GMT: Friday, 22 June 2018 07:40:23Your time zone: piątek, 22 czerwca 2018 09:40:23 GMT+02:00 DST Yr Mon D... Read More
Script HW/SW AIX
Viewed 1628 times since Mon, Jun 4, 2018
#### pwd;clear;SERVER=`hostname`sleep 2;>/tmp/${SERVER};echo "##########################" >> /tmp/${SERVER};echo "DATE: " >> /tmp/${SERVER};echo "---------------------------------------------------------------------" >> /tmp/${SE... Read More
Display basic information about Physical Volumes
Viewed 962 times since Sun, Jun 3, 2018
# Small script to display some interesting information about Physical Volumes DISP="1"; ls -l /dev/hdisk* | awk '{print $10 " " $5 $6}' | sed -e "s:/dev/::" -e "s/,/ /"  | while read DISK MAJOR MINORdo   SIZE=$(bootinfo -s $DISK)   LUN=$(... Read More
8 Practical Examples of Linux Xargs Command for Beginners
Viewed 813 times since Fri, Jun 1, 2018
The Linux xargs command may not be a hugely popular command line tool, but this doesn't take away the fact that it's extremely useful, especially when combined with other commands like find and grep. If you are new to xargs, and want to und... Read More
Linux and Unix xargs command tutorial with examples
Viewed 911 times since Fri, Jun 1, 2018
Tutorial on using xargs, a UNIX and Linux command for building and executing command lines from standard input. Examples of cutting by character, byte position, cutting based on delimiter and how to modify the output delimiter. Estimated reading time... Read More
10 Xargs Command Examples in Linux / UNIX
Viewed 849 times since Fri, Jun 1, 2018
The xargs command is extremely useful when we combine it with other commands. This tutorials explains the usage of xargs command using few simple examples. These example will help you understand the basics of how xargs command works. But, once you un... Read More
Tunneling With SSH to Your Destination
Viewed 1214 times since Wed, May 30, 2018
Tunneling With SSH to Your Destination   January 2015 | by David Tansley   Print 1   Figure 1 Figure 2 With SSH, you can create a tunnel (port forwarding) to transfer data that will be encrypted. Using this tunnel, you can then connect t... Read More
Dealing with Funny Files
Viewed 967 times since Wed, May 30, 2018
Dealing with Funny Files   September 2015 | by David Tansley   Print 0     Sometimes AIX reports an odd file when you use an ls or find command but it’s not present on the system. It can be frustrating when you can’t remove it du... Read More
Utilities to Tidy Up Your Reports
Viewed 791 times since Wed, May 30, 2018
Utilities to Tidy Up Your Reports   October 2015 | by David Tansley   Print 0     We system administrators quite often have to generate reports either for ourselves or for management. When we generate reports, particularly ad-hoc ones, the o... Read More
Using Shell Redirection: All About the Here-Doc
Viewed 1256 times since Wed, May 30, 2018
Using Shell Redirection: All About the Here-Doc   June 2016 | by David Tansley   Print 1     When gathering information from remote AIX hosts using SSH (Secure Shell), it will definitely make your life a lot easier to write the commands with... Read More
Time conversion using Bash
Viewed 853 times since Fri, May 25, 2018
Time conversion using Bash   This article show how you can obtain the UNIX epoch time (number of seconds since 1970-01-01 00:00:00 UTC) using the Linux bash "date" command. It also shows how you can convert a UNIX epoch time to a human reada... Read More
Convert a human readable date to epoch with a shell script on OpenBSD and Mac OS X
Viewed 1229 times since Fri, May 25, 2018
Convert a human readable date to epoch with a shell script on OpenBSD and Mac OS X Dates can be quite challenging. Especially if you systematically want to use dates, for example to compare what date is older. If you would like to convert this dat... Read More
Linux / UNIX: Convert Epoch Seconds To the Current Time
Viewed 964 times since Fri, May 25, 2018
How do I convert Epoch seconds to the current time under UNIX or Linux operating systems? Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Ti... Read More
How to sort IP addresses in Linux
Viewed 895 times since Thu, May 24, 2018
How to sort IP addresses in Linux Answer: When you have a file ip.txt contains a list of IP addresses, e.g. 127.0.0.2 127.0.0.1 10.10.10.1 To sort it, you can use the following command # sort -t. -k1,1n -k2,2n -k3,3n -k4,4n ip.txt 10.10.10.1 127.0.... Read More
Usuwanie spacji z zmiennych w bash
Viewed 893 times since Tue, May 22, 2018
Usuwanie początkowych / „wiodących” spacji z zmiennej: ZMIENNA="${ZMIENNA#"${ZMIENNA%%[![:space:]]*}"}" Usuwanie końcowych / „wleczących” spacji z zmiennej: ZMIENNA="${ZMIENNA%"${ZMIENNA##*[![:space:]]}"}" Read More
perl podstawy
Viewed 844 times since Mon, May 21, 2018
View Config Files Without Comments
Viewed 982 times since Mon, May 21, 2018
I’ve been using the following grep invocations to trim comments out of config files     #grep ^[^#] /etc/httpd/conf/httpd.conf or #egrep -v "^#|^$" /etc/httpd/conf/httpd.conf or #grep -v "^#" /etc/httpd/conf/httpd.confsource: https://sysadminco... Read More
Adding a range of IPs in Linux
Viewed 862 times since Mon, May 21, 2018
In this short post I will show you how you can quickly add a range of IPs on any RedHat based system. When you have to add many IPs to a system this can be quite handy and save a lot of time. Normally when you add a new IP to a network interface in a... Read More