Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Back-ticks and bash

by Wiggins (Hermit)
on Oct 09, 2016 at 13:29 UTC ( [id://1173585]=note: print w/replies, xml ) Need Help??


in reply to Re: Back-ticks and bash
in thread Back-ticks and bash

What I remenbered was /usr/bin/[ which is an external program used for doing tests I believe, and that is still there. I always find bash syntax confusing and obscure.

It is always better to have seen your target for yourself, rather than depend upon someone else's description.

Replies are listed 'Best First'.
Re^3: Back-ticks and bash
by choroba (Cardinal) on Oct 09, 2016 at 20:10 UTC
    [ in bash is a synomym for test but it's not still a builtin. For backward compatibility, it behaves similarly to /usr/bin/[ , which means variables among its arguments are still expanded by the shell, which is not true for [[ . In other words, you have to write things like
    if [ "$x" = abc ]

    i.e. you need to quote the variables, while with `[[` you don't have to, as the shell processes the parameters before expansion:

    if [[ $x = abc ]]

    Also, `[[` introduces pattern matching [[ $x = ab* ]] and `=~` you might now from Perl.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1173585]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found