The following is a bash script which iterate over .csv files within a directory. The question is, I now have an expect script #!/usr/bin/expect
where I want to use the same for loop. How could I achieve that?
JavaScript
x
#!/bin/bash
for f in /path/*.csv
do
echo $f
done
Advertisement
Answer
You would write:
JavaScript
#!/usr/bin/env expect
foreach f [glob /path/*.csv] {
puts $f
}
Expect is an extension of Tcl. In addition to the expect
man page, a link to the Tcl command documentation will be helpful: https://www.tcl.tk/man/tcl8.6/TclCmd/contents.htm