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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by mwesticle

  1. mwesticle

    count pipes ("|") in a file

    Jeez... So much to choose from... Thanks everyone!!!
  2. mwesticle

    count pipes ("|") in a file

    I need a simple nawk, awk, or sed program (or anything else, really) that will count the number of pipe characters in a file. So, if my file looks like this: 222222222222222|2222|2222|222222||| |222222|222|222222222222||222| |||22222222|222222222|2|||222222222222| I need the program to return...
  3. mwesticle

    Need a Command (or Program)!!!

    I have a pipe-delimited file with 24 fields. It is sorted on the 24th field. I need a program (or command, awk, nawk, whatever) that will go record-by-record, and flag every record where the 24th field is the same as the previous record AND field 19 is DIFFERENT (from the previous record)...
  4. mwesticle

    awk, nawk???

    Hi. I have a fixed width file, that is 62 bytes wide. The first 50 bytes are irrelevant to me. Bytes 51-62 are what I'm interested in, here. Starting in position 51, there is a number that is one to 12 bytes wide. I want to alter the file, padding any non-12-byte number with zeros, to fill...
  5. mwesticle

    MMS API

    Hello, I have a question that someone here, hopefully, can answer... My project team at work is developing a java-based product that will automatically send email messages, SMS messages, and MMS messages in real-time. We are dealing with brokers to handle the sending and receiving of email...
  6. mwesticle

    Easy UNIX file question...

    I have a fixed-width file that contains records that are 20-bytes long, and 12 of those bytes make up an "individual id" field. the remaining 8 bytes contain "other" information. The "individual id" may or may not be unique across records. So, for example, the contents of my file might look...
  7. mwesticle

    Select Records (awk, nawk, sed???)

    I need to select certain records from a file. The records are pipe-delimited, and therefore variable-length. The last two fields on the record are the onew I am concerned with. I want to pull records where the 2nd-to-last field = 'Y', and the last field = 'N'. For example, out of these four...
  8. mwesticle

    Join two files (sort of)

    Thanks for the suggestion, but this just seems to spit out File A. What I mean is, the resulting file (File C) is EXACTLY the same (byte-for-byte) as File A. I'm using this command: awk '{print;system("grep \"^"substr($0,1,12)"\" fileB")}' fileA > fileC What I'm looking for here is an output...
  9. mwesticle

    Join two files (sort of)

    I have an easy to semi-difficult problem here, and I was wondering if any of the good people at Tek-Tips could help me out... Here goes: I have two files (File A and File B), each have records that are 100 bytes in length. There are 12-digit "keys" on each file, in positions 1-12. File A is...
  10. mwesticle

    append two pipes ('|')

    I have a file that conatains roughly 700,000 records. I need a quick way to append two pipe characters to the end of each record. So, If input looks like this: aaa|bbb|ccc aaaa|bbbb|cccc nnnnnnnnnnnnnnnnn Output needs to look like this: aaa|bbb|ccc|| aaaa|bbbb|cccc|| nnnnnnnnnnnnnnnnn||...
  11. mwesticle

    find the longest record in a file

    I need to run something ('awk', 'sed', etc.) that will let me know what the longest record in a file is. And I need it to ignore spaces. So, if I have a file with records that look like this (without the ticks): 'John Doe' 'Al Doe' 'Christopher Doe' 'Jill Doe' I want the returned result to...
  12. mwesticle

    insert header into a file

    Perfect! Thanks!
  13. mwesticle

    insert header into a file

    Very easy question here: I have a file that contains pipe-delimited data. I need to insert a header record, without overwriting any data records. So, if the input file looks like this: John Doe|123 Main St|New York|NY|10101 Jane Doe|456 Oak St|Chicago|IL|12345 I need the output file to...
  14. mwesticle

    convert fixed-width file to a pipe delimited file

    It worked! Thanks again!
  15. mwesticle

    convert fixed-width file to a pipe delimited file

    OK, I'm now giving it the command: nawk 'BEGIN{j=split("1 7 21 36 41",s)}{for(i=1;i<j;++i){ a=substr($0,s[i],s[i+1]-s[i]);sub(/ *$/,"",a) printf a;if(i<j-1)printf "|";else printf "\n"}}' file.dat > file.dat.dlmt I am getting pretty much the same syntax error: nawk: syntax error at source...

Part and Inventory Search

Back
Top