Here's the busy part of the code. I've left out the preliminay setup and the final smbclient copy commands.
cd RAR echo "Getting RAR files from North Server" wget -q ftp://username:password@xxx.xxx.xxx.xxx/*.rar;type=i echo "Getting RAR files from South Server" wget -q ftp://username:password@xxx.xxx.xxx.xxx/*.rar;type=i echo "Unpacking RAR files" unrar -o+ -inul e *raw echo "Removing .rar files" rm *.rar echo "Renaming files and moving them to directories by type" for src in *; do type=$(echo $src | sed -e "s/^.*_//" | sed -e "s/.report//") tgt=$(echo $src | sed -e "s/\(^.*\)\.\(.*_.*\)/\2/") echo "Moving $src to ../$type/$tgt" mv $src ../$type/$tgt done cd ../CRS echo "Processing CRS files" for src in *.report; do # Set some variables type=$(echo $src | sed -e "s/^........//" | sed -e "s/\(^...\).*/\ +1/") dest=$(echo $src | sed -e "s/report/csv/") tid=$(echo $src | sed -e "s/_.*$//") echo "Src= $src" echo "Type=$type" echo "Dest=$dest" echo "TID= $tid" echo "" # Check to see if this is a Flashwave if [ $type = "FOS" ] \ || [ $type = "FOT" ] \ || [ $type = "FOU" ] ; then # If it is a Flashwave... echo "This is a flashwave" cat $src | sed -e "/FILL,0,$/d" > /tmp/sedtemp else # If this is NOT a Flashwave... echo "This is NOT a flashwave" cat $src | sed -e "/FILL,0,$/d" | sed -n "/,[1-2][,-].*,$/ { h N s/^.*,\(.*\),$/\1/ H x s/\n//g p } /,[0-9]\{1,2\}.*,$/ p" > /tmp/sedtemp fi # Find each Port ID section and duplicate it using , instead of - cat /tmp/sedtemp | uniq | # Special case - no dash in Port ID, just a single number #sed -e 's/\(,[0-9]\{1,2\}\)$/\1,,,,,/' | # Cleanup caused by special case #sed -e 's/,,,,,\([0-9]\{1,2\}\)$/,,,,\1,,,,,/' | # Special case - no dash in Port ID, just a single number sed -e 's/\(,[0-9]\{1,2\}\),$/\1,,,,,/' | # Main Port ID reformat sed -e 's/,\([0-9]\{0,2\}\)-\([0-9]\{0,2\}\)-\{,1\}\([0-9]\{0,2\}\ +)-\{,1\}\([0-9]\{0,2\}\)-\{,1\}\([0-9]\{0,2\}\)/,\1-\2-\3-\4-\ 5-,\1,\2,\3,\4,\5/g' | # Delete mulitple dashes sed -e 's/--/-/g' | # Do it again just to make sure sed -e 's/--/-/g' | # Delete trailing dashes sed -e 's/-,/,/g' > $dest # Update the tidlist echo "Updating tidlist" echo $tid >> ../tidlist.txt echo "" done

In reply to Re^2: BASH vs Perl performance by jcoxen
in thread BASH vs Perl performance by jcoxen

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.