This question already has an answer here:
I am writing a script which loops into recent files in a folder and executes a command...
#!/bin/bash
cd /home/Downloads
recent_files = ($(ls -t | head -20))
for file in "${recent_files[@]}"
do
./cmd $file
done
I get the following syntax error:
line 3: syntax error near unexpected token `('
line 3: `recent_files = ($(\ls -t | head -20))'
cd $HOME/Downloads
– Michael Durrant May 3 at 13:14recent_files=($(ls -t | head -20))
instead ofrecent_files = ($(ls -t | head -20))
no space arround equal. – Archemar May 4 at 8:29