IT Questions and Answers :)

Thursday, January 23, 2020

This question is categorized "General Linux" because it has been tested on Linux with "grep". Which of the following strings is NOT matched by the regular expression 'ca*t'

This question is categorized "General Linux" because it has been tested on Linux with "grep". Which of the following strings is NOT matched by the regular expression 'ca*t'

  • cart
  • cat
  • caat
  • ct 

This question is categorized "General Linux" because it has been tested on Linux with "grep". Which of the following strings is NOT matched by the regular expression 'ca*t'

EXPLANATION

cart  does NOT match the regular expression  ca*t  because  the  "r"   in "cart" is not matched.   

caat  matches the "c", the "a" (two times), and the "t" in the regular expression.
cat  matches the  "c", the  "a" (one time), and the  "t"  in the regular expression.
ct  matches the  "c",  the  "a"  (zero times),  and the "t"  in the regular expression.

From:  https://linux.die.net/man/1/grep
"Repetition
A regular expression may be followed by one of several repetition operators:

?
The preceding item is optional and matched at most once.

*
The preceding item will be matched zero or more times.

+
The preceding item will be matched one or more times. "
Note that "bash" will use  *  on the command line to match any string of characters in filenames.  

To match any string of characters with a regex use:     .*    
The period is a regex metacharacter matching any character except newline, and the asterisk metacharacter will expand matches to any length.

Since the asterisk is a globbing character to "bash", it should be escaped when entered on the bash command line with "grep".

Note that the asterisk is escaped in the command below so that bash does not expand the  '*'

$ grep  ca'*'t regex_test
ct
cat
caat
The asterisk could also be escaped to bash via  'ca*t'  or  ca\*t       Escaping passes the  to grep, instead of bash using it to glob filenames in the current directory.

Absent escaping, you could get unexpected results if the asterisk globs a filename:

$ ls
cannot  regex_test  test4
 
$ cat regex_test
ct
cat
caat
cannot
cart
chat

Below, the asterisk is NOT escaped, so bash expanded it to a filename:
$ grep ca*t regex_test
cannot





In the unescaped command above, filename "cannot" was globbed from  ca*t  and passed to grep, making the grep command expand to   "grep cannot regex_test"
Since the file "regex_test" contains the string "cannot" in its data, the results of "grep" are correct for the given command, but that command may have been unintended.

Compare the output of the unescaped  *  above, to the escaped  '*'  in the command below:
$ grep 'ca*t' regex_test
ct
cat
caat

If an unescaped asterisk is parsed by bash, but does not expand to a filename, bash will pass the asterisk to grep (or whatever other command was entered on the command line).  But don't count on bash not  globbing a filename when that's not what you want--always escape characters that are special to bash if you need them passed to your command.

From https://www.tldp.org/LDP/abs/html/globbingref.html
"Bash itself cannot recognize Regular Expressions. Inside scripts, it is commands and utilities -- such as sed and awk -- that interpret RE's.
Bash does carry out filename expansion [1] -- a process known as globbing -- but this does not use the standard RE set. Instead, globbing recognizes and expands wild cards. Globbing interprets the standard wild card characters [2] -- * and ?, character lists in square brackets, and certain other special characters (such as ^ for negating the sense of a match). There are important limitations on wild card characters in globbing, however. Strings containing * will not match filenames that start with a dot, as, for example, .bashrc. [3] Likewise, the ? has a different meaning in globbing than as part of an RE."

Lastly, this is old (but maintained), and a very good writeup on regular expressions: 
http://www.grymoire.com/Unix/Regular.html#TOC


SOURCE

https://linux.die.net/man/1/grep
Share:

Wednesday, January 22, 2020

Which version of Exchange is NOT supported to be a hybrid server?

Which version of Exchange is NOT supported to be a hybrid server?

  • 2016
  • 2013
  • 2010
  • 2007

Which version of Exchange is NOT supported to be a hybrid server?

EXPLANATION

The version of Exchange you have installed in your on-premises organization determines the hybrid deployment version you can install.
You should typically configure the newest hybrid deployment version that's supported in your organization. For example, if your on-premises organization is running Exchange 2007, you need to configure an Exchange 2013-based hybrid deployment.

SOURCE

https://docs.microsoft.com/en-us/exchange/hybrid-deployment-prerequisites
 

Share:

Friday, January 17, 2020

In an Active Directory Domain, the group policy is applied in what order?

In an Active Directory Domain, the group policy is applied in what order?

  • Child OU, Parent OU, Domain – Does not affect Sites or local machine policies.
  • Child OU, OU, Domain, Site, Local Machine.
  • Local Machine policy, then Site, then Domain, then OU, and finally the Child OU
  • OU, Child OU, Domain, Site – Does not affect local machine policies. 
In an Active Directory Domain, the group policy is applied in what order?


EXPLANATION

Order in which policies are applied
You can link Group Policy Objects throughout the hierarchical structure of the Active Directory environment. When you have different policies at different levels, they are applied in the following order unless you explicitly configure them to block inheritance or behave differently:
Local Group Policy Objects are applied first.
Site-level Group Policy Objects are applied in priority order.
Domain-level Group Policy Objects are applied in priority order.
Organizational Unit-level Group Policy Objects are applied in priority order down the hierarchical structure of your organization, so that the last Group Policy Object used in the one that applies to the Organizational Unit the user or computer resides in.
As this set of rules suggests, a Group Policy Object linked to a site applies to all domains at the site. A Group Policy Object applied to a domain applies directly to all users and computers in the domain and by inheritance to all users and computers in organizational units and containers farther down the Active Directory tree.
A Group Policy Object applied to an organizational unit applies directly to all users and computers in the organizational unit and by inheritance to all users and computers in its child organizational units.
You can modify the specific users and computers the GPO is applied to by choosing a different point in the hierarchy, blocking the default inheritance, using security groups to create Access Control Lists, or defining WMI filters.

 

Share:

Where are you most likely to find a rubber duck used for troubleshooting?

Where are you most likely to find a rubber duck used for troubleshooting?

  • Community manager's desk
  • Datacenter infrastructure testing
  • Networking tool kit
  • Software developer's desk 
Where are you most likely to find a rubber duck used for troubleshooting?

EXPLANATION

A rubber duck in use by a developer to aid code review. In software engineering, rubber duck debugging is a method of debugging code. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, ... It referenced rubber ducking as a powerful method for solving



Share:

What is the difference between a bit and a byte?

What is the difference between a bit and a byte?

  • They are the same.
  • A byte is 256 bits.
  • A byte is eight bits.
  • One measures bandwidth, the other throughput. 


EXPLANATION

Actually no, there's a big difference between a bit and a byte. A byte is much bigger — eight times bigger, to be exact, with eight bits in every byte. By extension, there are eight megabits in every megabyte, and one gigabyte is eight times bigger than one gigabit.

Share:

Popular Posts