user807133
user807133

Reputation: 43

Get a file content in Bash after expanding its variables

cat file

$VAR

cat script

#!/bin/bash
CONTENT=$(<file)
echo $CONTENT

./script

$VAR

I'd like to get the variable's actual value, not "$VAR". How to get a weaker quoting? Many thanks!

Upvotes: 4

Views: 5078

Answers (1)

Blagovest Buyukliev
Blagovest Buyukliev

Reputation: 43508

This should do it:

CONTENT=$(eval echo -e `<file`)

Upvotes: 3

Related Questions