Score:-1

how make Filename from Variable value

Is there any bash code for making the file name from a Variable value? ex\

x="IMP"
date > x.txt

output

IMP.txt
Score:0
us flag

Yes. On the bash command line, define a variable like this:

X="test.file"

and then create a file with this name like this:

touch "$X"

The quotes around the $X are present to take care of possible spaces in the filename.
Now ls -A will confirm you the existence of this file:

-rw-rw-r--  1 kubuntu kubuntu        0 Dez  2 01:06  test.file

And you can add content to this file like this:

date >> "$X"

which will add the output of date to the file.
Of course, the scope of this variable X is limited to the current bash/shell instance.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.