bash - check if file exists by taking input from a file -


need script dose following checks if files exists read input file compares them files listed in directory if don’t exists script report file dose not exists. need format output files grouped in different groups, group a, b, , c , etc based on file name. output of not exists files sorted based on second number in file name group according. understand of basics of bash scripting along of lines of loop , if statements might trick. below have far. don’t car script reporting file exists prefer know if file missing , less 3 days old.

  • group

    foo22000.tar.gz foo22010.tar.gz 
  • group b

    foo25000.tar.gz foo25100.tar.gz 
  • group c

    foo26000.tar.gz 

so have working solution problem if file missing compared against wrong file ie. won’t work obvious. because compare foo3 against foo4 since foo3 did not exists how solve problem?

file list /home/foo/foo1 /home/foo/foo2 /home/foo/foo3 /home/foo/foo4

report file /home/foo/foo1 /home/foo/foo2 /home/foo/foo4

find ~/ -name “foo*” –mtime -3 print>report sort report –o report while read comp1 <&3 && comp2 <&4 do if [[ $comp1 = comp2 ]] then echo “file found” >/dev/null else echo “$comp1 not found” fi done 3<report 4<list

file=/home/foo  filestr=find /home/foo  –name “foo*” –mtime -3 print file_it in $(find /home/foo  –name “foo*”)    fl_it_basename=$(basename $file_it)    grep ${fl_it_basename) $fichier_group_a >/dev/null 2>&1    if [ $? -ne 0 ]          /// file not present        else      /// file present           fi done 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -