I am using awk inside of the bash script to print a new file contained the name of the variable defined in bash
#!/bin/bash
file_name='test.log'
awk -v file="$file_name" '
BEGIN {
print "@ subtitle \"file\""
}
in that case the awk prints
@ subtitle "file"
instead of the expected output
@ subtitle "test.log"
>Solution :
You cannot use a variable in a string as-is but you can concatenate between a string and a variable like so:
print "@ subtitle " file ""
In this case, the empty string "" is useless, but it is just as an example. So you can just get rid of it and it will behave same with/without it.
print "@ subtitle " file
In your case, you want something like this:
print "@ subtitle \"" file "\""