Skip to main content
Re-tag, minor formatting improvement
Source Link
AdminBee
  • 23.6k
  • 25
  • 56
  • 77

The below code is working:

[ec2-user@ip restore]$ echo $snap_name
manual-test-2024-01-11-11-26-19
[ec2-user@ip restore]$  aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating
[ec2-user@ip-10-0-39-226 restore]$
[ec2-user@ip restore]$ echo $snap_name
manual-test-2024-01-11-11-26-19
[ec2-user@ip restore]$  aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating
[ec2-user@ip-10-0-39-226 restore]$

But when trying to get the output as a variable, it is getting an error:

[ec2-user@ip restore]$ snap_count=`aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating`
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
[ec2-user@ip restore]$
[ec2-user@ip restore]$ snap_count=`aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating`
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
[ec2-user@ip restore]$

Please suggest here.

The below code is working:

[ec2-user@ip restore]$ echo $snap_name
manual-test-2024-01-11-11-26-19
[ec2-user@ip restore]$  aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating
[ec2-user@ip-10-0-39-226 restore]$

But when trying to get the output as a variable, it is getting an error:

[ec2-user@ip restore]$ snap_count=`aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating`
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
[ec2-user@ip restore]$

Please suggest here.

The below code is working:

[ec2-user@ip restore]$ echo $snap_name
manual-test-2024-01-11-11-26-19
[ec2-user@ip restore]$  aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating
[ec2-user@ip-10-0-39-226 restore]$

But when trying to get the output as a variable, it is getting an error:

[ec2-user@ip restore]$ snap_count=`aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating`
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
[ec2-user@ip restore]$

Please suggest here.

Source Link

unexpected EOF while looking for matching `'' when using backticks as variable

The below code is working:

[ec2-user@ip restore]$ echo $snap_name
manual-test-2024-01-11-11-26-19
[ec2-user@ip restore]$  aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating
[ec2-user@ip-10-0-39-226 restore]$

But when trying to get the output as a variable, it is getting an error:

[ec2-user@ip restore]$ snap_count=`aws rds describe-db-cluster-snapshots --db-cluster-identifier creditpoc3 --query 'DBClusterSnapshots[].{DBClusterSnapshotIdentifier:DBClusterSnapshotIdentifier,Status:Status} | [?DBClusterSnapshotIdentifier == `'"$snap_name"'`']'' | grep creating`
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: command substitution: line 1: unexpected EOF while looking for matching `''
-bash: command substitution: line 2: syntax error: unexpected end of file
[ec2-user@ip restore]$

Please suggest here.