这看起来很简单,从第一个字段列出目录,然后从第二个字段列出目录。输入文件中的字段以逗号分隔,例如:XXXX1111111111112222,cool.com
。
我运行命令:
./list_directories some_file.csv
list_directories
脚本是这样的:
#!/bin/bash
INPUT=$1
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read WORKING STORE
do
echo $STORE
ls $STORE
echo $WORKING
ls $WORKING
done < $INPUT
IFS=$OLDIFS
这是输出:
/pathtothe/som/coolplace/Imlookingfor/cool.com/place/123/XXXX1111111111112222 : No such file or directorye/Imlookingfor/cool.com/place/123/XXXX1111111111112222 /pathtothe/som/coolplace/Imlookingfor/cool.com/placing/123/XXXX1111111111112222 fileindir.txt otherfileindir.txt lastofthefilesindir.txt
我知道两个目录都存在。不确定我是否被卷入了IFS。