Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting an outpust file

Status
Not open for further replies.

Cimm

Technical User
Feb 17, 2005
69
US
I cant come up with a smooth way to do this.
But I have an ftp output file that looks like this.

/users/ftp4csc/bad_files/dummy.DAT /extracts/test/bad_files/dummy.DAT
/users/ftp4csc/bad_files/dummy.txt /extracts/test/bad_files/dummy.txt
/users/ftp4csc/bad_files/dummy1.txt /extracts/test/bad_files/dummy1.txt
/users/ftp4csc/checks/dummy2.txt /extracts/cntrl/Comm/dummy2.txt
/users/ftp4csc/checks/dummy3.txt /extracts/cntrl/Comm/dummy3.txt

This is just a small part of it, but in certain directories I only want to download *.DAT files from bad_files directories, and ignore the rest from that particular directory. The rest to be leaved intact.

Any idea's?
Thanks in advance
 
So I take it you want to filter the filenames that you don't want out of that output?

Something like:

Code:
awk '
        # display if in bad_files and with .DAT extension,
        # skip to next record
        /bad_files/ && /.DAT/ {print ; next}
        # otherwise skip other bad_files
        /bad_files/ { next }
        # display all other (non bad) files
        { print }
' old_file > new_file

Annihilannic.
 
That worked perfect, thank you very much!.
 
How come the above code you gave isnt working when I try it on a single column.

/extracts/test/bad_debt/dummy.DAT
/extracts/test/bad_debt/dummy.txt
/extracts/test/bad_debt/dummy1.txt
/extracts/integ_cntrl/pointInComm/dummy2.txt
/extracts/integ_cntrl/pointInComm/dummy3.txt

I dont see anything in the awk that indicates you need 2 column text file for this code to work.

The above code is correct and needed. I am just trying to figure out why it doesnt on this text file.

Once again , thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top