#!/bin/bash
$'\141'
string1="$'\\"
number=141
string2="'"
result="${string1}${number}${string2}"
$result
Running this script gives this response:
./temp.sh: line 2: a: command not found
./temp.sh: line 8: $'\141': command not found
Why are these two not equivalent? What would need to be changed in the second attempt to get the correct ASCII conversion?
Clearly the second try isn't being converted to 'a' as expected. Why is this? I thought maybe because I escaped the special meaning of backslash by doing \\. But if that's the case, does it mean it's not possible to do this ASCII conversion on a constructed string?
For additional information, this is for a CTF where I must run cat ../../flag or equivalent without using any letters. So I'm trying to use an ASCII conversion.
If you have error, it's simply a syntax error.
What you need to construct
ASCIIletters from variables:or to construct from multiple variables (only 2 needed):
From
POSIXOpen Group:See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html