I'm trying to create a script that goes line by line in a file, extracts the last word in each sentence and performs another script I created (which works, called intermediate) and prints all of that as separate lines.
For some reason I get an endless loop.
function find_id {
next_file="${*:2}"
temp_file="`echo $next_file | cut -d"." -f1`"
if [[ $temp_file != station ]]; then
while read line; do
if [[ -f "${temp_file}.station" ]]; then
train_col=$((${#line[*]}-1))
$train_id=`echo ${line[${train_col}]}`
echo -n "`intermediate $train_id`"
fi
done < ${temp_file}.station
next_file="`echo $next_file | cut -d"." -f2- | cut -d" " -f2-`"
temp_file="`echo $next_file | cut -d"." -f1`"
echo "`find_id $1 $next_file`"
fi
}
file_list= `ls *.station``
echo "`find_id $1 $file_list``" | sort -n | cut -d" " -f2- | uniq
I'm not allowed to use awk or sed.