Reputation: 41
I want to write a script which prompts the user for the names of two files, lists the first file on screen and waits for user to press any key before second file is listed on the screen. But I am unsure of how to do this. Could anyone help? I think its something like:
VALID_FILENAME_ONE="Test1"
VALID_FILENAME_TWO="Test2"
echo "Please enter first file name:"
read file_name1
echo "Please enter second file name:"
read file_name2
if [ "$file_name1" == "$VALID_FILENAME_ONE"]; then
ls -l | Test1
else
echo "No further action"
fi
But this does not run correctly. Any help would be much appreciated.
Upvotes: 0
Views: 507
Reputation: 2279
In the following line:
if [ "$file_name1" == "$VALID_FILENAME_ONE"]; then
... add a space between "$VALID_FILENAME_ONE" and the closing square bracket, like this:
if [ "$file_name1" == "$VALID_FILENAME_ONE" ]; then
Otherwise, bash can't parse your syntax.
Upvotes: 1