while read dir ev file; do
# do stuff
done
The part I can’t find an explanation for is the read dir ev part. I’m not familiar with Bash. I mainly do PHP and MySQL. Can anyone explain?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The short version is, it takes a single line at a time from the input and assigns individual fields from it into variables.
read dir ev filewould read lines one by one and expect each line to contain 3 items. It would then assign the first item into a variable nameddir, the second into a variable namedev, and the third into a variable namedfile.From the output of
help read:(Edit: more readable version here: http://ss64.com/bash/read.html)