BASH shell script to quickly create and populate new test files
# for i in {1..5} do echo "New File $i" > file$i done
-bash: syntax error near unexpected token `>'
I tried the above single line script that failed with the error above. I am trying to automate the input process:
echo "New File" > file1
echo "New File" > file2
echo "New File" > file3
echo "New File" > file4
echo "New File" > file5
I am trying to do this without creating a script file, for example below:
#!/usr/bin/env bash
for i in {1..5}
do
echo "New File $i" > file$i
done
This script works, but I want to be able to do something like this on a single line from the command line.
I understand that the problem is with redirecting >to a file. I tried to avoid redirecting a >few other things and googling, but I did not come up with something that worked.
, cli, , , script.
1
, , :
# for i in {1..5} do ; echo "New File $i" > file$i ; done
-bash: syntax error near unexpected token `echo'
2
Update 1. , , .