0

Content of my file named /tmp/tmp.txt is

Allow
- 's3:GetObject'
arn:aws:s3::*:${dtddyuffjf}/*
Allow
- 'SQS:GetMessage'
${DocServiceQueue.Arn}
Allow
- ec2:CreateNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:DeleteNetworkInterface
*

I am passing this to a variable like below v1= $(cat /tmp/tmp.txt)

echo $v1 showing

Allow

  • 's3:GetObject' arn:aws:s3:::${dtddyuffjf}/ Allow
  • 'SQS:GetMessage' ${DocServiceQueue.Arn} Allow
  • ec2:CreateNetworkInterface
  • ec2:DescribeNetworkInterfaces
  • ec2:DeleteNetworkInterface and instead of the * , it's showing content of the folder It does not show *
Subit Das
  • 15
  • 4

1 Answers1

0

Try echo with double quotes:

echo "$v1"

echo * is equivalent to ls. The shell will treat it as 'ls' command and will list the files in that directory.

Just for your reference try running below:

echo *

and

echo "*"
Homer
  • 424
  • 3
  • 7
  • See the "Answer Well-Asked Questions" section of [How to Answer](https://stackoverflow.com/help/how-to-answer), particularly including the bullet point regarding questions that "have been asked and answered many times before". – Charles Duffy Sep 17 '20 at 19:25
  • (and no, `echo *` and `ls` do not have identical behavior; both are rather poorly defined, but `echo *` is considerably less reliable -- see the APPLICATION USAGE section of the [POSIX `echo` specification](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html), keeping in mind that filenames are effectively undefined -- they _can_ contain backslash escape sequences, names like `-n`, etc). – Charles Duffy Sep 17 '20 at 19:27