3.1.2 Quoting
-------------

Quoting is used to remove the special meaning of certain characters or
words to the shell.  Quoting can be used to disable special treatment
for special characters, to prevent reserved words from being recognized
as such, and to prevent parameter expansion.

   Each of the shell metacharacters (*note Definitions::) has special
meaning to the shell and must be quoted if it is to represent itself.
When the command history expansion facilities are being used (*note
History Interaction::), the HISTORY EXPANSION character, usually '!',
must be quoted to prevent history expansion.  *Note Bash History
Facilities::, for more details concerning history expansion.

   There are three quoting mechanisms: the ESCAPE CHARACTER, single
quotes, and double quotes.

3.1.2.1 Escape Character
........................

A non-quoted backslash '\' is the Bash escape character.  It preserves
the literal value of the next character that follows, with the exception
of 'newline'.  If a '\newline' pair appears, and the backslash itself is
not quoted, the '\newline' is treated as a line continuation (that is,
it is removed from the input stream and effectively ignored).

3.1.2.2 Single Quotes
.....................

Enclosing characters in single quotes (''') preserves the literal value
of each character within the quotes.  A single quote may not occur
between single quotes, even when preceded by a backslash.

3.1.2.3 Double Quotes
.....................

Enclosing characters in double quotes ('"') preserves the literal value
of all characters within the quotes, with the exception of '$', '`',
'\', and, when history expansion is enabled, '!'.  The characters '$'
and '`' retain their special meaning within double quotes (*note Shell
Expansions::).  The backslash retains its special meaning only when
followed by one of the following characters: '$', '`', '"', '\', or
'newline'.  Within double quotes, backslashes that are followed by one
of these characters are removed.  Backslashes preceding characters
without a special meaning are left unmodified.  A double quote may be
quoted within double quotes by preceding it with a backslash.  If
enabled, history expansion will be performed unless an '!' appearing in
double quotes is escaped using a backslash.  The backslash preceding the
'!' is not removed.

   The special parameters '*' and '@' have special meaning when in
double quotes (*note Shell Parameter Expansion::).

source :https://www.gnu.org/software/bash/manual/bash.txt
$echo quote ls
quote ls
$echo 'quote ls'
quote ls
$echo 'quote ls`
> ;
> ^C
$echo `quote ls`
'ls'
$echo `ls`
animal.png animal.xcf icon.png
$ls
animal.png  animal.xcf  icon.png
$ls `quote ls`
ls: cannot access 'ls': No such file or directory
$ls 'quote `ls`'
ls: cannot access quote `ls`: No such file or directory
$echo  'quote `ls`'
quote `ls`
$echo  `quote `ls``
''ls
$echo  "quote `ls`"
quote animal.png
animal.xcf
icon.png
$echo  'quote `ls`'
quote `ls`
$echo  'ls  `ls`'
ls  `ls`
$quote "ls pwd"
'ls pwd'$
$quote "ls pwd \n"
'ls pwd \n'$
$ls `quote ls`
ls: cannot access 'ls': No such file or directory
$ls `ls`
animal.png  animal.xcf  icon.png
$


commandline session

$netstat --tcp
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 debian.local:39585      74.125.169.8:http       ESTABLISHED
tcp        0      0 debian.local:39586      74.125.169.8:http       ESTABLISHED
tcp        0      0 debian.local:47951      maa03s17-in-f6.1e:https ESTABLISHED
tcp        0      0 debian.local:47203      maa03s17-in-f0.1e1:http ESTABLISHED
$
$netstat --tcp --numeric
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        1      0 192.168.0.101:54541     46.22.210.18:80         CLOSE_WAIT
tcp        0      0 192.168.0.101:54542     46.22.210.18:80         ESTABLISHED
tcp        0      0 192.168.0.101:39585     74.125.169.8:80         ESTABLISHED
tcp        0      0 192.168.0.101:39586     74.125.169.8:80         TIME_WAIT
tcp        0      0 192.168.0.101:47951     74.125.236.198:443      ESTABLISHED
tcp        0      0 192.168.0.101:47203     74.125.236.192:80       ESTABLISHED
$netstat --tcp --numeric
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 192.168.0.101:54542     46.22.210.18:80         TIME_WAIT
tcp        0      0 192.168.0.101:39585     74.125.169.8:80         ESTABLISHED
tcp        0      0 192.168.0.101:39586     74.125.169.8:80         TIME_WAIT
tcp        0      0 192.168.0.101:47951     74.125.236.198:443      ESTABLISHED
tcp        0      0 192.168.0.101:47203     74.125.236.192:80       ESTABLISHED
$netstat --tcp --listen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *:35436                 *:*                     LISTEN
tcp        0      0 *:sunrpc                *:*                     LISTEN
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 localhost:smtp          *:*                     LISTEN
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN
tcp6       0      0 [::]:501100              [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN
$netstat --tcp --listen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *:35436                 *:*                     LISTEN
tcp        0      0 *:sunrpc                *:*                     LISTEN
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 localhost:smtp          *:*                     LISTEN
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN
tcp6       0      0 [::]:501100              [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN
$netstat --tcp --program
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 debian.local:39600      74.125.169.8:http       ESTABLISHED 3846/chrome
tcp        0      0 debian.local:47951      maa03s17-in-f6.1e:https ESTABLISHED 3846/chrome
tcp        0      0 debian.local:47203      maa03s17-in-f0.1e1:http ESTABLISHED 3846/chrome
$
$netstat --tcp --route
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         192.168.0.1     0.0.0.0         UG        0 0          0 eth0
192.168.0.0     *               255.255.255.0   U         0 0          0 eth0
$netstat --tcp --statistics
IcmpMsg:
    OutType3: 1
Tcp:
    522 active connections openings
    0 passive connection openings
    14 failed connection attempts
    16 connection resets received
    2 connections established
    60302 segments received
    41524 segments send out
    22 segments retransmited
    21 bad segments received.
    140 resets sent
UdpLite:
TcpExt:
    190 TCP sockets finished time wait in fast timer
    495 delayed acks sent
    1 delayed acks further delayed because of locked socket
    Quick ack mode was activated 32 times
    47899 packet headers predicted
    1353 acknowledgments not containing data payload received
    406 predicted acknowledgments
    7 congestion windows recovered without slow start after partial ack
    22 other TCP timeouts
    32 DSACKs sent for old packets
    3 DSACKs sent for out of order packets
    5 DSACKs received
    25 connections reset due to unexpected data
    16 connections reset due to early user close
    TCPSackShiftFallback: 2
    TCPChallengeACK: 21
    TCPSYNChallenge: 21
IpExt:
    InMcastPkts: 929
    OutMcastPkts: 42
    InBcastPkts: 16
    OutBcastPkts: 14
    InOctets: 83827635
    OutOctets: 2776707
    InMcastOctets: 332300
    OutMcastOctets: 5264
    InBcastOctets: 1808
    OutBcastOctets: 1006
$

Bash – netstat ( network statistics related ) – Video Tutorial Related

[ source : http://www.youtube.com/user/metalx1000 ]



commandline session

$ > test file
Usage: file [-bchikLlNnprsvz0] [--apple] [--mime-encoding] [--mime-type]
            [-e testname] [-F separator] [-f namefile] [-m magicfiles] file ...
       file -C [-m magicfiles]
       file [--help]
$ls
test
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
$> "test file"
$ls
test  test file
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test file
$> test
test       test file
$> test  newfile
bash: newfile: command not found
$> test newfile
$ls
test  test   test file  test newfile
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test file
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test newfile
$> test  newfile
$ls -l
total 0
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  8 23:59 test file
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:00 test newfile
-rw-r--r-- 1 jeffrin jeffrin 0 Nov  9 00:01 test  newfile
$

the following video tutorial content may not be fully accurate



GNU Command

$tee name
my name is nice.
my name is nice.
$cat name
my name is nice.
$

Explanation


Copy standard  input to each  FILE, and also  to standard
output.  A  special variant of  the tee for the  shell is
called script and  permits duplicating all input commands
submitted to a shell into a file.

Related Source Code Exposition

static bool
tee_files (int nfiles, const char **files)
{
  FILE **descriptors;
  char buffer[BUFSIZ];
  ssize_t bytes_read;
  int i;
  bool ok = true;
  char const *mode_string =
    (O_BINARY
     ? (append ? "ab" : "wb")
     : (append ? "a" : "w"));

  descriptors = xnmalloc (nfiles + 1, sizeof *descriptors);

  /* Move all the names `up' one in the argv array to make room for
     the entry for standard output.  This writes into argv[argc].  */
  for (i = nfiles; i >= 1; i--)
    files[i] = files[i - 1];

  if (O_BINARY && ! isatty (STDIN_FILENO))
    xfreopen (NULL, "rb", stdin);
  if (O_BINARY && ! isatty (STDOUT_FILENO))
    xfreopen (NULL, "wb", stdout);

  /* In the array of NFILES + 1 descriptors, make
     the first one correspond to standard output.   */
  descriptors[0] = stdout;
  files[0] = _("standard output");
  setvbuf (stdout, NULL, _IONBF, 0);

  for (i = 1; i <= nfiles; i++)
    {
      descriptors[i] = (STREQ (files[i], "-")
                        ? stdout
                        : fopen (files[i], mode_string));
      if (descriptors[i] == NULL)
        {
          error (0, errno, "%s", files[i]);
          ok = false;
        }
      else
        setvbuf (descriptors[i], NULL, _IONBF, 0);
    }

  while (1)
    {
      bytes_read = read (0, buffer, sizeof buffer);
#ifdef EINTR
      if (bytes_read < 0 && errno == EINTR)
        continue;
#endif
      if (bytes_read <= 0)
        break;

      /* Write to all NFILES + 1 descriptors.
         Standard output is the first one.  */
      for (i = 0; i <= nfiles; i++)
        if (descriptors[i]
            && fwrite (buffer, bytes_read, 1, descriptors[i]) != 1)
          {
            error (0, errno, "%s", files[i]);
            descriptors[i] = NULL;
            ok = false;
          }
    }

  if (bytes_read == -1)
    {
      error (0, errno, _("read error"));
      ok = false;
    }

  /* Close the files, but not standard output.  */
  for (i = 1; i <= nfiles; i++)
    if (!STREQ (files[i], "-")
        && descriptors[i] && fclose (descriptors[i]) != 0)
      {
        error (0, errno, "%s", files[i]);
        ok = false;
      }

  free (descriptors);

  return ok;
}

Source Code Highlight

Copy the standard input into  each of the NFILES files in
FILES  and  into the  standard  output.   Return true  if
successful.

Featured Image
FIXME

Related Knowledge

The  `tee'  command  copies  standard input  to  standard
output and also to any files given as arguments.  This is
useful when  you want not only  to send some  data down a
pipe, but also to save a copy.