Bash Shell Programming HowTos

Tutorials, howtos and programming tips about GNU Bourne-Again SHell (BASH) for Apple OS X, Linux, *BSD and Unix like operating systems. ( rss feed )

I need to find out in which directory my bash script resides so that I can read config file called .backup .ignore .target. For example, if my script resides in >/home/foo/script.sh, I need to read /home/foo/.{backup,ignore,target} files. How do I find out the current directory location and shell script directory location in Bash running on Linux or Unix like operating systems?

{ 10 comments }

How can I fetch HTML web page content from bash and display on screen using shell utilities?

{ 4 comments }

I am using awk to grep ‘foo’ from a text file and cacluate sum of field # 7. But, result is rounded to an integer. I need exact result such as 385858.66 and not 385858 using the following command:

grep ‘foo’ 2012-2013.txt | awk ‘BEGIN{ sum=0.0}{ sub(“,”,””,$7); sum +=$7}END{ print “$” sum}’
$682444

I want $682444.57 as output. How can I force “awk” to do floating point math?

{ 1 comment }

I am a desktop support professional with experience working in a corporate call center environment. Recently, I started to admin RHEL based IBM Linux server. How do I determine how much disk space left in my Linux server? How do I find out how much disk space I have in Linux for each partition?

{ 10 comments }

I am a new Linux user. How do I find out size of a directory on Linux operating systems using command line options?

{ 11 comments }

I have a text file as follows:

foo
bar
foobar

How can I delete all leading and/or trailing blank spaces, tab from each line using sed command?

{ 5 comments }

I‘m a new Linux system user. How can I redirect command error output /dev/null on a Linux or Unix-like system using Bash shell?

{ 4 comments }