简体   繁体   中英

Bash scripting - using if in a for loop

I am total noob in bash scripting and do not know what the problem is within my code; I am writing an sh extension file that will be used as a buffer into the Linux sys. This is just a practice but I do not know what the problem within the code really is, can someone tell me?

Thanks

在此处输入图片说明

This is the answer I came up with in the end

#!/bin/bash
>oldFiles.txt
files=$(grep ' jane ' ../data/list.txt | cut -d ' ' -f 3)
for x in $files;
do 
    if test -e ../data/$x; then echo $x >> oldFiles.txt; else echo $x; fi;
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM