bash: dealing with strange filenames tail invalid option --1
03:01 24 May 2017

I want my script to find a file (in the current directory) with the first line equal to START. Then that file should have FILE as the last line. So I want to extract the - I use tail for this. It works ok for standard file names but cracks for nonstandard file names like a a or a+b-c\ = e with tail reporting tail option used in invalid context -- 1

Here is the beginning of the script:

#!/bin/bash

next_stop=0;

# find the first file
start_file=$(find . -type f -exec sed '/START/F;Q' {} \;)
mv "$start_file" $start_file       # << that trick doesn't work

if [ ! -f "$start_file" ]
then
  echo "File with 'START' head not found."
  exit 1
else
    echo "Found $start_file"
fi

# parse the last line of the start file
last_line=$(tail -1 $start_file)    # << here it crashes for hacky names
echo "last line: $last_line"
if [[ $last_line == FILE* ]] ; then 
    next_file=${last_line#* }
    echo "next file from last line: $next_file"
elif [[ $last_line == STOP ]] ; then
        next_stop=true;
    else
        echo "No match for either FILE or STOP => exit"
        exit 1
    fi

I tried to embrace the find output with braces this way

mv "$start_file" $start_file

but it doesn't help

bash filenames tail