vi failed_curlybraces.sh
#!/bin/sh
echo "Let's create a file with youname!"
echo "What's you name"
read INPUT_NAME
echo "Hoy! $INPUT_NAME, Creating a file with $INPUT_NAME_lovely.txt
touch "INPUT_NAME_lovely.txt"
echo "Hurrraaahhh! nooo fileee created"
If you run the script, it won't create the file. As the shell doesn't know where the variable ends. So now, modify the script.
vi correct_curlybraces.sh
#!/bin/sh
echo "Let's create a file with youname!"
echo "What's you name"
read INPUT_NAME
echo "Hoy! ${INPUT_NAME}, Creating a file with ${INPUT_NAME}_lovely.txt
touch "{INPUT_NAME}_lovely.txt"
echo "Hurrah! file created"
***
No comments:
Post a Comment