shell command

How do I assign the output of a shell command to a shell variable under Unix like operating system? For example, I want to store the date command output to a variable called $now. How do you do that?

{ 12 comments }

How do I use the bash C style for loop under UNIX or Linux operating systems?

{ 2 comments }

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 I display shell command history with date and time under UNIX or Linux operating systems?

{ 31 comments }

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

{ 5 comments }

Q. I’d like to find out if xyz package is available or not using apt-get command. How do I look up package names and contents via shell command? A. You need to use apt-cache command to performs a variety of operations on APT’s package cache. apt-cache does not manipulate the state of the system but […]

{ 0 comments }