Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Bash difference in single quotes and double quotes     - Performance Optimization: Using Ramlog transfer log files to memory (Linux)

- Linux operating system Start Tutorial: Xmanager Remote Access Linux graphical interface (Linux)

- Upgrading to Debian 7.6 glibc 2.15 (Linux)

- Household use Linux Security (Linux)

- Oracle 12C RAC on temporary table space Enlighten (Database)

- How to install Ubuntu strategy game Wesnoth 1.12.0 (Linux)

- MySQL InnoDB table --BTree basic data structures (Database)

- Linux System Getting Started Learning: rename multiple files in Linux (Linux)

- Linux installed xdotool simulate keystrokes and mouse movements (Linux)

- Applications in Objective-C runtime mechanism (Programming)

- Python object-oriented programming (Programming)

- RT-11SJ run at ambient PDP-11 MACRO-11 assembly (Programming)

- How to query the role of Linux services (Linux)

- Android will save the picture to see the album and timely (Programming)

- C # get the current screenshot (Programming)

- Changes in C # asynchronous programming model (Programming)

- Difference Docker mirror and containers (Server)

- Depth understanding of C language (Programming)

- CentOS 6.4 dial-up Raiders (Linux)

- Linux system security configuration (Linux)

 
         
  Bash difference in single quotes and double quotes
     
  Add Date : 2018-11-21      
         
         
         
  Bash distinction of single and double quotes

Single quote: Must be used in pairs, it can protect all of the characters are not translated. Variables such as $ 1, and an odd number of single quotes the same effect, even a single quote = 1 pair of quotes
Double quotes: must be paired, it can protect some meta characters are not translated, but allows variable and command substitution, and the role of the same even number of single quotes
Backslash \: shell does not interpret character escapes \ after '$ 1' and '\ $ 1 "as
Single and double quotes can protect each other

Example 1:

$ Cat test.sh

#! / Bin / bash

echo "$ 1" = $ 1 "$ 2" = $ 2
echo '$ 1' = $ 1 '$ 2' = $ 2

$ ./test.sh Hello world
hello = hello world = world
$ 1 = hello $ 2 = world

Example 2:

#! / Bin / bash

echo '$ 1' = $ 1
echo '$ 1' = '$ 1'
echo '$ 1' = "$ 1" // a double quotation mark
echo '$ 1' = $ 1
echo '$ 1' = '$ 1'
echo '$ 1' = '' $ 1 '' // two single quotes

Example 3:

Single quotes backslash is not translated
$ Echo '\\'
\\

Example 4:

Protection of single quotes double quotes
$ Echo 'Mother yelled, "Time to eat!"'
Mother yelled, "Time to eat!"

Example 5:

Double quotes single quotes protection
$ Echo "Hi, I'm glad to mee you"
Hi, I'm glad to meet you
     
         
         
         
  More:      
 
- To install and use Docker under linux (Server)
- Java open source monitoring platform Zorka basic use (Linux)
- Linux formatted partition error Could not stat / dev / sda No such file or directory Solution (Linux)
- Spring WebSocket Comments (Programming)
- Install Rubinius testing Ubuntu 14.04 native threads (Linux)
- Gentoo: existing preserved libs problem solving (Linux)
- Python system default encoding (Programming)
- Build and verify MongoDB3.0.7 version (shard + replica) Cluster (Database)
- Java implementation of stacks and queues (Programming)
- Git use and interpretation of common commands (Linux)
- How to experience Unity 8 Mir on Ubuntu 16.04 (Linux)
- Linux character device - a simple character device model (Linux)
- Oracle11g CRS-0184 Problem Solving (Database)
- Build the first ASP.NET 5 Web project in Mac OS X Yosemite 10.10.3 (Server)
- Oracle database NUMBER (x, y) data types (Database)
- dmidecode command Detailed (Hardware information) (Linux)
- Precautions against hackers Linux environment (Linux)
- To upgrade combat MongoDB database replication sets and split versions (Database)
- Oracle for Oracle GoldenGate to achieve a one-way synchronization DDL operations (Database)
- Ubuntu 15.04 installation Powercommands 2.0 (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.