Category:TXR: Difference between revisions
Content added Content deleted
(Ported to Windows natively.) |
(→Simple Query: Extremely simple query.) |
||
Line 17: | Line 17: | ||
The success of a directive means that computation proceeds to the next directive (and, if this is a pattern match, the input position advances). Failure means that the enclosing query fails, triggering back-tracking behaviors and possibly failure of the entire query. |
The success of a directive means that computation proceeds to the next directive (and, if this is a pattern match, the input position advances). Failure means that the enclosing query fails, triggering back-tracking behaviors and possibly failure of the entire query. |
||
==Extremely Simple Query== |
|||
Extract first matching line from the password file. Of course, TXR matches are not restricted to single line! |
|||
<lang bash>$ txr -c '@(skip) |
|||
@user:@pw:@uid:@gid:@gecos:@home:@shell' /etc/passwd</lang> |
|||
<pre> |
|||
user="root" |
|||
pw="x" |
|||
uid="0" |
|||
gid="0" |
|||
gecos="root" |
|||
home="/root" |
|||
shell="/bin/bash"</pre> |
|||
Now, pre-bind the <code>user</code> variable first to retrieve some other user. Now <code>@(skip)</code> kicks into action, skipping non-matching material: |
|||
<lang bash>$ txr -Duser=sshd -c '@(skip) |
|||
@user:@pw:@uid:@gid:@gecos:@home:@shell' /etc/passwd</lang> |
|||
<pre>user="sshd" |
|||
pw="x" |
|||
uid="114" |
|||
gid="65534" |
|||
gecos="" |
|||
home="/var/run/sshd" |
|||
shell="/usr/sbin/nologin"</pre> |
|||
==Simple Query== |
==Simple Query== |