Skip to content

Instantly share code, notes, and snippets.

@mulderu
Last active May 15, 2018 04:41
Show Gist options
  • Save mulderu/d8b33f7c5563377fde17e89ac6cb09c3 to your computer and use it in GitHub Desktop.
Save mulderu/d8b33f7c5563377fde17e89ac6cb09c3 to your computer and use it in GitHub Desktop.
bash, file read, loop, work
#!/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
@mulderu
Copy link
Author

mulderu commented Dec 9, 2017

file read jpg and png and make merge list has .txt

$ cat test1.sh
#!/bin/bash

ppp="/label"
k=1
for file in *.{jpg,png}
do
#echo $file
if [ -f "${file:0:15}txt" ]
then
#echo "Good $k ==> $file"
echo "$ppp/$file" >> all_file.data
((k = k+1))
fi
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment