Bash Articles RSS Feed
Transform XML to CSV Format | Unix String Pattern Manipulation The Ugly Way
Viewed 5197 times since Sun, Jan 9, 2022
Transform XML to CSV Format | Unix String Pattern Manipulation The Ugly Way Updated: Jun 22, 2020     Disclaimer: I do not claim the below method to be the best optimum method of transforming XML to CSV format on the Unix command p... Read More
30 Handy Bash Shell Aliases For Linux / Unix / MacOS
Viewed 4542 times since Thu, Feb 11, 2021
30 Handy Bash Shell Aliases For Linux / Unix / MacOS Author: Vivek Gite Last updated: October 28, 2020 186 comments An bash shell alias is nothing but the shortcut to commands. The alias command allows the user to launch any command or group of... Read More
awk printf
Viewed 14924 times since Wed, Aug 19, 2020
https://riptutorial.com/awk$$$$$ MATH: $$$$$ Find the remainder of 1 number divided by another use "%" -->>> echo 27 5 | awk '{print $1 % $2}' -->> 2 Comparisons: -->>> echo 4 5 | awk '{if ($1 < $2... Read More
10 Awk Tips, Tricks and Pitfalls
Viewed 5861 times since Wed, Aug 19, 2020
10 Awk Tips, Tricks and Pitfalls Last updated 3 weeks ago Hi guys and girls, this is the first and only guest post on my blog. It's written by Waldner from #awk on FreeNode IRC Network. He works as a sysadmin and does shell scripting as a hob... Read More
How to get a password from a shell script without echoing - solutions
Viewed 13534 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 2102 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 2068 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 31483 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 2139 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 2904 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 14684 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 13189 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 12343 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 61497 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 9064 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 3324 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 5372 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 3795 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 3803 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 4207 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 2413 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 16187 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 10245 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 2627 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 14977 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 2971 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 3793 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 2388 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 1978 times since Mon, May 21, 2018
View Config Files Without Comments
Viewed 2142 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 2546 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