Tutorial by Examples: e

The Standard (10.4) states: Member functions can be called from a constructor (or destructor) of an abstract class; the effect of making a virtual call (10.3) to a pure virtual function directly or indirectly for the object being created (or destroyed) from such a constructor (or destructor) is u...
Most, but not all, C++ implementations support the #pragma once directive which ensures the file is only included once within a single compilation. It is not part of any ISO C++ standard. For example: // Foo.h #pragma once class Foo { }; While #pragma once avoids some problems associated w...
Installation Volley JCenter Gradle Import //in your project's app level build.gradle compile 'com.android.volley:volley:1.0.0' Create a subclass of Application public class AppController extends Application { public static final String TAG = AppController.class .getSimpleN...
.set-colors(@type) when (@type = error) { @base-color: #d9534f; background: @base-color; color: contrast(@base-color, lighten(@base-color, 25%), darken(@base-color, 25%)); border: 1px solid contrast(@base-color, lighten(@base-color, 25%), darken(@base-color, 25%)); } .set-colors(@type)...
There are two common ways to list all processes on a system. Both list all processes running by all users, though they differ in the format they output (the reason for the differences are historical). ps -ef # lists all processes ps aux # lists all processes in alternative format (BSD) Thi...
VariableDetails$* / $@Function/script positional parameters (arguments). Expand as follows:$* and $@ are the same as $1 $2 ... (note that it generally makes no sense to leave those unquoted)"$*" is the same as "$1 $2 ..." 1 "$@" is the same as "$1" "$2&qu...
An environment variable pointing to the Bash startup file which is read when a script is invoked.
An array containing the full version information split into elements, much more convenient than $BASH_VERSION if you're just looking for the major version: ~> $ for ((i=0; i<=5; i++)); do echo "BASH_VERSINFO[$i] = ${BASH_VERSINFO[$i]}"; done BASH_VERSINFO[0] = 3 BASH_VERSINFO[1] =...
Shows the version of bash that is running, this allows you to decide whether you can use any advanced features: ~> $ echo $BASH_VERSION 4.1.2(1)-release
The default editor that will be involked by any scripts or programs, usually vi or emacs. ~> $ echo $EDITOR vi
To get the name of the current function - type: my_function() { echo "This function is $FUNCNAME" # This will output "This function is my_function" } This instruction will return nothing if you type it outside the function: my_function echo "This function i...
The home directory of the user ~> $ echo $HOME /home/user
The hostname assigned to the system during startup. ~> $ echo $HOSTNAME mybox.mydomain.com
This variable identifies the hardware, it can be useful in determining which binaries to execute: ~> $ echo $HOSTTYPE x86_64
Outputs the line number in the current script. Mostly useful when debugging scripts. #!/bin/bash # this is line 2 echo something # this is line 3 echo $LINENO # Will output 4
Similar to $HOSTTYPE above, this also includes information about the OS as well as hardware ~> $ echo $MACHTYPE x86_64-redhat-linux-gnu
Returns information about the type of OS running on the machine, eg. ~> $ echo $OSTYPE linux-gnu
The number of seconds a script has been running. This can get quite large if shown in the shell: ~> $ echo $SECONDS 98834
A readonly list of the options bash is supplied on startup to control its behaviour: ~> $ echo $SHELLOPTS braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
Positional parameters passed to the script from either the command line or a function: #!/bin/bash # $n is the n'th positional parameter echo "$1" echo "$2" echo "$3" The output of the above is: ~> $ ./testscript.sh firstarg secondarg thirdarg firstarg sec...

Page 578 of 1191