0

So I have a list file that goes like this:

SOURCE_FILE|SOURCE_SYSTEM|DELIVERY_FREQUENCY|IMPORT_DIRECTORY|PROCESSING_BLOCKS|DEPENDENT_DELIVERY_CODES|AFFECTED_TARGET_SYSTEMS

example:

SUBMIT_303_EXOTICIIBOND_YYYYMMDD_V01_T23.xml.gz|STF|DAILY|fromSTF|FLOWS|SMTMM|CFP;
YYYYMMDD_PES_TER_99_99.tar.gz|PALO|MONTHLY|fromPO|IRBDD|PES_TER|CFP

and a directory with the files:

SUBMIT_303_EXOTICIIBOND_20220720_V01_T23.xml.gz;
20220720_PES_TER_99_99.tar.gz).

I need to check if the file from the list really exists and if not write it into file.

I was able to create the script to sort out the names of files that I need cat file_path | grep "DAILY" | cut -d '|' -f1 so it's just the names of files.

Any suggestions on how to implement the output into !-f with the daily changing dates?

1
  • So I was able to write a code to filter out only the names of files and add current date as well, right now I need some suggestions with checking if the files in grep do really exist. cat /project/almvv_import_control_table.csv | grep "DAILY" | cut -d '|' -f1 | sed "s/YYYYMMDD/$(date '+%Y%m%d')/" Commented Jul 22, 2022 at 9:30

1 Answer 1

1

I've been diving deeper into recently:

gawk -F'|' '
  @load "filefuncs"
  $3 == "DAILY" {
    result = stat($1, statdata)
    if (result != 0)
      print $1
  }
' file.list > files.not.found

Or, expressed as a one-liner:

gawk -l filefuncs -F'|' '$3 == "DAILY" && stat($1, data) {print $1}' file.list > files.not.found

Ref https://www.gnu.org/software/gawk/manual/html_node/Extension-Sample-File-Functions.html

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.