Skip to main content
added 7 characters in body
Source Link
heemayl
  • 58.1k
  • 9
  • 129
  • 144

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

ResposeResponse:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with $' ' vs string wrapped with $" " in bash echobash's echo?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Respose:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with $' ' vs string wrapped with $" " in bash echo?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Response:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with $' ' vs string wrapped with $" " in bash's echo?

Tweeted twitter.com/StackUnix/status/766225468857131008
Corrected title to match question
Source Link
DopeGhoti
  • 79.2k
  • 10
  • 107
  • 141

What is the difference between single quoted 'string'$'string' and double quoted "string"$"string" in bash echo?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Respose:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with '$' ' vs string wrapped with "$" " in bash echo?

What is the difference between single quoted 'string' and double quoted "string" in bash echo?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Respose:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with ' ' vs string wrapped with " " in bash echo?

What is the difference between single quoted $'string' and double quoted $"string" in bash?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Respose:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with $' ' vs string wrapped with $" " in bash echo?

added 8 characters in body; edited title
Source Link

What is the difference between single quoted 'string' and double quoted "string" in bash echo?

What is the difference between single quoted 'string' and double quoted "string" in bash echo?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Respose:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with ' ' vs string wrapped with " " in bash echo?

What is the difference between 'string' and "string" in bash echo?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Respose:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with ' ' vs string wrapped with " " in bash echo?

What is the difference between single quoted 'string' and double quoted "string" in bash echo?

I was trying to execute new line using echo and tried following two commands:

  1. First command:

     echo $'Hello World\nThis is a new line'
    

Respose:

    Hello World
    This is a new line
  1. Second command:

     echo $"Hello World\nThis is a new line"
    

Response:

    Hello World\nThis is a new line

My question is what's the difference between string wrapped with ' ' vs string wrapped with " " in bash echo?

deleted 1 character in body
Source Link
techraf
  • 6.1k
  • 11
  • 36
  • 51
Loading
deleted 2 characters in body
Source Link
techraf
  • 6.1k
  • 11
  • 36
  • 51
Loading
deleted 22 characters in body; deleted 2 characters in body
Source Link
techraf
  • 6.1k
  • 11
  • 36
  • 51
Loading
Source Link
Loading