bash startup variable expression

I have the idea that I would like to add an environment variable (“waitTillReady”) to my ~/.bashrc file, such that instead of doing this:

while [ "$ (pidof -s make)" -o "$ (pidof -s gcc)" -o "$ (pidof -s ld)" ]; do echo "Still compiling..." && sleep 1; done && printf "\n%.0s" {1..20} && date && echo "THINGS ARE READY FOR YOU NOW..."

I want to be able to do this: $ waitTillReady && echo "THINGS ARE READY FOR YOU NOW..."

I tried to edit my ~/.bashrc file like with different combinations of the following:

... export waitTillReady="while [ "$  (pidof -s make)" -o "$  (pidof -s gcc)" -o "$  (pidof -s ld)" ]; do echo "Still compiling..." && sleep 1; done && printf "\n%.0s" {1..20} && date" ... 

E.g. I tried to enclose everything insider a single quote ‘ and I tried to escape the \” in the middle… Could anyone please help and tell what I should write in the ~/.bashrc file, after the “export waitTillReady=” line?

I would be grateful to hear any suggestions/ideas (and maybe an explanation of what I’m doing wrong), thanks!

Regular expression properties

I’m reading Aho and Ullman’s book The Theory of Parsing, Translation, and Compiling. In the section that introduces regular expressions in chapter 2, there is a list of properties of regular expressions. I do not understand properties 2 and 8. Here is the list of properties:

(1) $ \alpha + \beta = \beta + \alpha$

(2) $ \varnothing * = e$

(3) $ \alpha + (\beta + \gamma) = (\alpha + \beta) + \gamma$

(4) $ \alpha(\beta\gamma) = (\alpha\beta)\gamma$

(5) $ \alpha(\beta + \gamma) = \alpha\beta + \alpha\gamma$

(6) $ (\alpha + \beta)\gamma = \alpha\gamma + \beta\gamma$

(7) $ \alpha e = e \alpha = \alpha$

(8) $ \varnothing\alpha = \alpha\varnothing = \varnothing$

(9) $ \alpha * = \alpha + \alpha *$

(10) $ (\alpha *)* = \alpha *$

(11) $ \alpha + \alpha = \alpha$

(12) $ \alpha + \varnothing = \alpha$

where $ \varnothing$ is the regular expression denoting the regular set $ \varnothing$ , $ \alpha$ , $ \beta$ , $ \gamma$ are arbitrary regular expressions, and $ e$ is the empty string.

How are properties (2) and (8) justified?

Edit: To explain the notation of +, *, etc, here are some definitions given in the book (quoted):

DEFINITION A langauge over an alphabet $ \Sigma$ is a set of strings over $ \Sigma$ .

DEFINITION Let $ L_1$ be a language over alphabet $ \Sigma_1$ and $ L_2$ a language over $ \Sigma_2$ . Then $ L_1 L_2$ , called the concatenation or product of $ L_1$ and $ L_2$ , is the language $ \{xy|x \in L_1\textrm{ and }y \in L_2\}$ .

DEFINITION The closure of $ L$ , denoted $ L*$ , is defined as follows:

(1) $ L^0 = {e}$ .

(2) $ L^n = LL^{n-1}$ for $ n \geq 1$ .

(3) $ L* = \bigcup_{n \geq 0} L^n$ .

DEFINITION Let $ \Sigma$ be a finite alphabet. We define a regular set over $ \Sigma$ recursively in the following manner:

(1) $ \varnothing$ (the empty set) is a regular set over $ \Sigma$ .

(2) $ {e}$ is a regular set over $ \Sigma$ .

(3) $ {a}$ is a regular set over $ \Sigma$ for all $ \alpha$ in $ \Sigma$ .

(4) If $ P$ and $ Q$ are regular sets over $ \Sigma$ , then so are

(a) $ P \cup Q$ .

(b) $ PQ$ .

(c) $ P*$ .

(5) Nothing else is a regular set.

Thus a subset of $ \Sigma *$ is regular if and only if it is $ \varnothing$ , $ {e}$ , or $ {a}$ , for some $ a$ in $ \Sigma$ , or can be obtained from these by a finite number of applications of the operations union, concatenation, and closure.

.

DEFINITION Regular expressions over $ \Sigma$ and the regular expressions they denote are defined recursively, as follows:

(1) $ \varnothing$ is a regular expression denoting the regular set $ \varnothing$ .

(2) $ e$ is a regular expression denoting the regular set $ {e}$ .

(3) $ a$ in $ \Sigma$ is a regular expression denoting the regular set $ {a}$ .

(4) If $ p$ and $ q$ are regular expressions denoting the regular sets $ P$ and $ Q$ , respectively, then

(a) $ (p+q)$ is a regular expression denoting $ P \cup Q$ .

(b) $ (pq)$ is a regular expression denoting $ PQ$ .

(c) $ (p)*$ is a regular expression denoting $ P*$ .

(5) Nothing else is a regular expression.

Closed form expression for $Tr\left[ (\mathbf{DW})^k \right]$

Given the $ N \times N$ diagonal matrices $ \mathbf{D}$ and $ \mathbf{W}$ as defined below

\begin{equation} \begin{split} \mathbf{DW} &= \frac{1}{{M N}} \left[ \begin{array}{cccc} \beta_{1} & 0 & \cdots & 0 \ 0 & \beta_{2} & \cdots & 0\ \vdots & \vdots & \ddots & \vdots \ 0 & 0 & \cdots & \beta_{N} \ \end{array} \right] % \left[ \begin{array}{cccc} M & \sum_{m=0}^{M-1}{\mbox{e}^{-i m \pi \theta_{1,2}}} & \cdots & \sum_{m=0}^{M-1}{\mbox{e}^{-i m \pi \theta_{1,N}}} \ \sum_{m=0}^{M-1}{\mbox{e}^{-i m \pi \theta_{2,1}}} & M & \cdots & \sum_{m=0}^{M-1}{\mbox{e}^{-i m \pi \theta_{2,N}}}\ \vdots & \vdots & \ddots & \vdots \ \sum_{m=0}^{M-1}{\mbox{e}^{-i m \pi \theta_{N,1}}} & \sum_{m=0}^{M-1}{\mbox{e}^{-i m \pi \theta_{N,2}}} & \cdots & M \ \end{array} \right] \end{split} \end{equation}

where $ \theta_{i,j} = \theta_{j,i}$ .

I would like to know if there is a closed form for \begin{equation} Tr\left[ (\mathbf{DW})^k \right], \end{equation} where $ Tr[.]$ is the matrix trace operator and $ k$ is an integer greater than or equal to 1.

So far I have been able to manually find up to $ Tr\left[ (\mathbf{DW})^3 \right]$ but it gets too cumbersome for $ k \geq 4$ . But perhaps, hopefully, someone out there knows a closed form for this.

Counting number of states from a regular expression

Given the regular expression: $ r=ab+((a+\epsilon)c^*)^*$ . Let A be a non-deterministic automaton that accepts the language of r. How many states are in A? Answer the question without building A explicitly, explain how you got the answer.

I’m having trouble figuring this question out. The answer that was given is: $ 5*2+4*2=18$

With the explanation that for the $ \epsilon$ regular expression we build an automaton with 2 states.

for each $ \sigma \in \Sigma$ for the regular expression $ \sigma$ we build an automaton with 2 states

For concatenating we do not add states and for each union or star operation we add 2 states.

But even with this explanation I’m not quite sure did they reach this answer.

I can understand that we have $ \epsilon$ , so we have 2. Plus we have $ \Sigma = \{a,b,c\}$ so we do $ 2*3$ .

Even with the stars, how do we reach $ 5*2$ ?

Also I haven’t seen this kind of calculation before, are there any additional rules when trying to calculate states from a regular expression?

sed: -e expression #1, char 3: extra characters after command

I’m totally new (starting from 0) to the world of Linux, programming and ‘ask ubuntu’.I have just started experimenting as I’m working on a uni project that requires me to.

I am trying to run an example :

sed '$  LNZs/.*/N_Z  = 1/' <>$  FTNZ 

and I keep getting the error in the title.

I would appreciate any help as I couldn’t figure out from answers to previous questions having close to ‘0’ basic knowledge atm.

Thanks

sed: -e expression #1, char 3: extra characters after command

I’m totally new (starting from 0) to the world of Linux, programming and ‘ask ubuntu’.I have just started experimenting as I’m working on a uni project that requires me to.

I am trying to run an example :

sed '$  LNZs/.*/N_Z  = 1/' <>$  FTNZ 

and I keep getting the error in the title.

I would appreciate any help as I couldn’t figure out from answers to previous questions having close to ‘0’ basic knowledge atm.

Thanks