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...
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)...
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...
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...
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...
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...
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...
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...
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||...
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...
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...
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...
I think we're really close to getting there. I'm getting a syntax error... It seems to have a problem with "printf". What do you think?
nawk: syntax error at source line 1
context is
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)...
Yes, I think that could work... What would this nawk look like if the fixed-width fields were variable length, meaning field one was bytes 1-6, field two was bytes 7-20, field three was bytes 21-35, and field three was bytes 36-40? Know what I mean? What if they weren't all exactly ten bytes???
Hi All...
I have what is probably a very easy question for the experts that patrol this board...
I have a fixed-width file with four 10-byte fields (field 1 = bytes 1-10, field 2 = bytes 11-20, field 3 = bytes 21-30, field 4 = bytes 31-40). Some of the fixed-width fields contain no spaces, or...
OK. Here's my dilemma... I have a file with a bunch of 12-byte "ID's" on it. It looks like this:
111111111111
999999999999
222222222222
999999999999
333333333333
222222222222
...and so on.
Anyway, here's the criteria: I want to take this file, do "something" to it, and, when that...
If I have a file where all of the records have trailing spaces... like this (without the single quotes):
'123 Main '
'456 Central Ave '
'789 Oak Street '
How do I take this file, and strip the trailing spaces, so my output looks like this (without the single quotes):
'123 Main'...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.