redirecting help

I am trying to create the file and redirect the output in the same command line which is line 4 in the below program.


#!/bin/bash
read -p "Enter File Name:" value1
echo "Your File Name is $value1"
sed 's/abcd/'$value1'/g' abcd_calls > $value1_calls

This is the error it generates

./code.sh: line 4: $value1_calls: ambiguous redirect

It is not redirecting since $value1_calls such file does not exist as i want to create the file with name of input ($value1 given by user through read command) .

sed 's/abcd/'$value1'/g' abcd_calls > ${value1}_calls

That's because there is no variable named "$value1_calls".

use "${value1}_calls" instead.

try making the file after getting user input i.e.after

read -p "Enter File Name:" value1
echo "Your File Name is $value1"
vi $value1 #this will create the file,that can be edited now!!