I want the user to be able to name a file to be created, and then have the output of the script redirected to that file. The script will create a long listing of a directory and count the number of files in that directory. This is what I have so far:
echo -n "Please enter the name of a file to be created: "
read FILENAME
touch FILENAME
ls -l exampledir
echo
ls -l exampledir | wc -l
I might not be using read correctly, I'm not too sure.
Edit
I figured most of it out, here is the new code:
echo -n "Please enter the name of a file to be created: "
read FILENAME
ls -l Assign_7 > FILENAME
echo >> FILENAME
ls -l Assign_7 | wc -l >> FILENAME
The only thing I can't figure out is how to get the file to be named what the user entered. It has the right stuff inside, but right now the file is always called FILENAME
2nd EDIT
Figured it out. Just needed to add $ before each FILENAME