Bash

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

device1,deviceType,major,minor,permissions
device2,deviceType,major,minor,permissions

….
..
deviceN,deviceTypeN,major,minor,permissions

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

{ 5 comments }

How do convert tabs to spaces in a file using a bash shell?

{ 6 comments }

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?

{ 31 comments }

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)?

{ 13 comments }

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?

{ 1 comment }

How do I use bash for loop in one line under UNIX or Linux operating systems?

{ 5 comments }

If var is defined AND NOT EMPTY, use var, otherwise set a default variable under Bash. For e.g. my script needs a parameter for output variable. It can be text or html. I set it as follows in my script

output=$1 # either text or html

However, sometime user forget to pass the parameter to my shell script and my enter logic fails. So how do I set default value to text, if no parameter passed?

{ 6 comments }