0

What is the error in that?

j=0
filenames=("")
filedates=("")

while read line
do
filenames[$j]="$line"
filedates[$j]=$(stat -c %y ${filenames[$j]} | cut -d ' ' -f1)
(( j++ ))
done < <(ls -t *.gz)

Out:

script.sh: line 9: syntax error near unexpected token `<'
script.sh: line 9: `done < <(ls -t *.gz)'

Really i don't know the error in that while loop, i tested it on several machine but same problem

0

2 Answers 2

2

The problem is that you're using bash specific <(process substition), but running your script with /bin/sh.

Use bash script.sh instead of sh script.sh, and make sure the shebang uses bash and not sh.

Sign up to request clarification or add additional context in comments.

Comments

1

use a for loop

for file in *t.gz
do
   ...
done

2 Comments

am still dummy in bash, can u please right the whole loop for me?
@user3178889 That would be a completely different thing altogether, and cause you to miss out on a valuable learning opportunity. We were all dummies once.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.