≡ Menu


Explains: echo Command (echo $”string”) Double-quoted String Preceded By a Dollar Sign

I noticed that many shell scripts in /etc/init.d/ directory use the following syntax:

echo $"Usage $prog start|stop|reload|restart"

Why a double-quoted string preceded by a dollar sign ($"string") using the echo command under Linux / UNIX bash scripts?
[click to continue…]

Append Current Date To Filename in Bash Shell

How do I append current date (mm_dd_yyyy format) to a filename (e.g., backup_mm_dd_yyyy.sql) under UNIX like operating systems?
[click to continue…]

UNIX / Linux: Kill All My Jobs Under Current Shell Session

How do I kill all the UNIX jobs I created under my current login shell such as Bash or KSH before logout?
[click to continue…]

Bash String Comparison: Find Out IF a Variable Contains a Substring

How do I determine whether a variable called spath="/srv/www/cyberciti.biz/https" contains a substring called "cyberciti.biz"?
[click to continue…]

Bash Shell Read a Line Field By Field

How do I read a file field-by-field under UNIX / Linux / BSD Bash shell? My sample input data file is as follows:


For each line I need to construct and execute a shell command as follows:
/path/to/deviceMaker --context=$1 -m $permissions $device2 $deviceType $major $minor
[click to continue…]

Bash Shell: Convert Tabs To Spaces In a File

How do convert tabs to spaces in a file using a bash shell?
[click to continue…]

Linux RAM Disk: Creating A Filesystem In RAM

Software RAM disks use the normal RAM in main memory as if it were a partition on a hard drive rather than actually accessing the data bus normally used for secondary storage such as hard disk. How do I create and store a web cache on a RAM disk to improve the speed of loading pages under Linux operating systems?
[click to continue…]

Linux/UNIX: Move File Starting With A Dash

In Unix or Linux operating systems, how do I move file(s) starting with a dash (e.g., /home/you/--filename.txt or /home/you/-filename.txt)?
[click to continue…]

HowTo: Unix For Loop 1 to 100 Numbers

I want to run a Unix command 100 times using a for loop from 1 to 100. Can you tell me how to take a block of numbers in a loop under KSH or BASH shell?
[click to continue…]

HowTo: Use bash For Loop In One Line

How do I use bash for loop in one line under UNIX or Linux operating systems?
[click to continue…]