Ana Sayfa / Linux / Bash Script / Importance of Quoting in Strings / Dizelerde Alıntı Yapmanın Önemi

Importance of Quoting in Strings / Dizelerde Alıntı Yapmanın Önemi

Quoting is important for string expansion in bash. With these, you can control how the bash parses and expands
your strings.

There are two types of quoting:

  • Weak: uses double quotes: “
  • Strong: uses single quotes: ‘

If you want to bash to expand your argument, you can use Weak Quoting:

#!/usr/bin/env bash
world="World"
echo "Hello $world"
#> Hello World

If you don’t want to bash to expand your argument, you can use Strong Quoting:

#!/usr/bin/env bash
world="World"
echo 'Hello $world'
#> Hello $world

You can also use escape to prevent expansion:

#!/usr/bin/env bash
world="World"
echo "Hello \$world"
#> Hello $world

For more detailed information other than beginner details, you can continue to read it here.

Bunada Göz Atın

PHP Types

Type Comparison There are two types of comparison: loose comparison with == and strict comparison …

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir