lundi 7 décembre 2020

Find diff over two text files in shell and execute an execute a command based on differences

I have two different text files (temp1.txt,temp2.txt) with results from multiple ls -l commands. I want to check the below using shell and in a if loop

  1. If the two *.txt files are same - execute xyz, exit since no action is required.
  2. If a filename is present only in temp1.txt and not in temp2.txt - execute abc
  3. If the filename is present only in temp2.txt and not in temp2.txt - execute jkl
  4. if file in temp1.txt is newer (based on timestamp) - execute awar

My *.txt files will be in this format with multiple lines

20201207 0050 0 wf135r217.config

I'm new to shell and could not do anything except the 1st step. Any help is appriciated.

Aucun commentaire:

Enregistrer un commentaire