bash file read and loop work example)
input file : t1
workjob : echo file line, wc -l : line count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
k=1 | |
input="t1" | |
while IFS= read -r var | |
do | |
echo "$k ]" | |
echo "$var" | |
cat "$var" | |
wc -l "$var" | |
echo "------------------------------------------------------" | |
(( k = k + 1 )) | |
done < "$input" | |
# --------------------------- | |
#!/bin/bash | |
k=1 | |
n_stt=200 | |
n_end=250 | |
input="f_list.txt" | |
rm test-files.txt train-files.txt | |
while IFS= read -r var | |
do | |
if (( k > n_stt && k <= n_end )); then | |
echo "$k is test" | |
echo $var >> test-files.txt | |
else | |
echo "$k is train" | |
echo $var >> train-files.txt | |
fi | |
(( k = k + 1 )) | |
done < "$input" | |
# file remove that it has not current dir | |
# | |
#!/bin/bash | |
files=`ls *.jpg | cut -c 1,-24 | awk '{print "../seg-caries/" $1 "_all.png" }'` | |
for f in $files | |
do | |
if [ ! -f "$f" ]; then | |
del_f=`echo $f | cut -c 15-38 | awk '{print "./" $1 ".jpg"}'` | |
rm -f $del_f | |
echo "del $del_f" | |
fi | |
done | |