Would there be an easier way to do this in perl?
#!/bin/tcsh #1. Create a file of all disk images from the Netbackup catalog that N +etbackup thinks is on disk. echo "Creating list of all images that Netbackup thinks is on disk." cp /dev/null catall grep "F:\\backup" cat.txt | sed -e "s/F:\\backup\\/\*/g" | awk -F\* '{ +print "F:\\backup\\" $2}' >> catall grep "G:\\backup" cat.txt | sed -e "s/G:\\backup\\/\*/g" | awk -F\* '{ +print "G:\\backup\\" $2}' >> catall grep "H:\\backup" cat.txt | sed -e "s/H:\\backup\\/\*/g" | awk -F\* '{ +print "H:\\backup\\" $2}' >> catall #2. Create file of what's on disk echo "Create file listing of all images on disk." cp /dev/null dirall grep "_" Fdir.txt | awk '{print "F:\\backup\\" $5}' > dirall grep "_" Gdir.txt | awk '{print "G:\\backup\\" $5}' >> dirall grep "_" Hdir.txt | awk '{print "H:\\backup\\" $5}' >> dirall #3. sort the files echo "Sorting the two files" sort catall > catall.srt sort dirall > dirall.srt #4. check em echo "Checking the differences." diff -u dirall.srt catall.srt |grep "^-" |grep -v "\-\-\-" |sed -e s/\ +-//g > delfile.list #5. create batch file echo "Creating a batch file to delete the files that Netbackup doesn't + know about." awk '{print "del " $1}' delfile.list > delfile.bat

Retitled by g0n from 'tcsh'.


In reply to Listing Files in a Directory (Translation From Shell Script) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.