≡ Menu

shell script

Linux / UNIX: Check If File Is Empty Or Not Using Shell Script

How do I check if file is empty or not using bash or ksh shell script under UNIX / Linux / OS X / BSD operating systems?
[click to continue…]

HowTo: Get Current Time In Shell Script

How do I get the current server time in shell script on Linux or Unix-like operating systems? How do I store the current time in the shell variable and use in my scripts?
[click to continue…]

Print a Web Page From a Shell Prompt

How do I print a web page from a shell prompt or shell script?
[click to continue…]

Linux Iptables Just Block By Country

I admin ecom website and a lot of bogus traffic comes from countries that do not offer much in commercial value. How do I just configure Apache or iptables to just refuse connections to certain countries?
[click to continue…]

Use BASH nullglob To Verify *.c Files Exists or Not In a Directory

Can you explain me usage of nullglob variable under BASH? How do I check for any *.c files in any directory?
[click to continue…]

Linux / UNIX: Convert Hexadecimal to Decimal Number

How do I convert hex number to decimal number using a shell script under UNIX / Linux operating systems?
[click to continue…]

/bin/bash: bad interpreter: Text file busy Error and Solution

Q. I'm getting an error as follows while trying to run a shell script over remote ssh session:

/bin/bash: bad interpreter: Text file busy

How do I fix this error message and run the script?
[click to continue…]

tsort: UNIX / Linux Perform Topological Sort

Q. How do I perform topological sort or topological ordering without writing code in C or other programming language? How do I performs a topological sort on the given FILE using a shell script?
[click to continue…]

Linux Gnome: Add Open Terminal Here / Open Shell Prompt Here Right Click Menu To a File Manager

Question: How do I open a shell prompt or gnome-terminal at the current location while browsing directories and files via nautilus file manager? I'd like to see Open Terminal / Prompt here option added to my right click menu. How do I open command prompt in a single selected directory or otherwise in current directory?
[click to continue…]

Explain: #!/bin/bash - or #!/bin/bash -- In A Shell Script

Q. I know #!/bin/bash is shebang line. But, I noticed a few shell script shebang line ends with a single dash ( #!/bin/bash - ) or double dash ( #!/bin/bash -- ). Can you explains me purpose of such shebang line?
[click to continue…]