Hi
Your logic works but i have a small correction in my requirement
the input file as i said will look like this
SANDI108085FRANKLIN WRAP 7285
SANDI109514ZIPLOC STRETCH N SEAL 7285
SANDI110198CHOICE DM 0911
SANDI111144RANDOM WEIGHT BRAND 0704
SANDI111144RANDOM WEIGHT BRAND 0738
The output should be in the format.
I need to know whether we can use printf '%s %-51s' in formatting in awk
SANDI FRANKLIN WRAP 108085 7285
SANDI ZIPLOC STRETHC N SEAL 109514 7285
SANDI CHOICE DM 110198 0911
SANDI RANDOM WEIGHT BRAND 111144 0704 0738
Hi
Also i have one more question
if we are using like this
arr[key]=sprintf("%s %s", arr[key], $NF)
We are creating a map or relationship between the key and the elements.
I would like to do a file processing of nearly 3GB size file.
If thisis the case will there be any memory issues coming out.
Hi
Your logic works but i have a small correction in my requirement
the input file as i said will look like this
SANDI108085FRANKLIN WRAP 7285
SANDI109514ZIPLOC STRETCH N SEAL 7285
SANDI110198CHOICE DM 0911
SANDI111144RANDOM WEIGHT BRAND 0704
SANDI111144RANDOM WEIGHT BRAND 0738
The output should be in the format.
SANDI FRANKLIN WRAP 108085 7285
SANDI ZIPLOC STRETHC N SEAL 109514 7285
SANDI CHOICE DM 110198 0911
SANDI RANDOM WEIGHT BRAND 111144 0704 0738
I need to know whether we can use printf '%s %-51s' in formatting in awk
Based on your sample: assuming consecutive repeated lines and some fixed widths:
awk 'END { print s } {
one = substr($1,1,5)
two = substr($1,6,6)
three = substr($1,12)
if (one FS three != t) {
print s
s = ""
}
$1 = t = one FS three
_ = $NF; $NF = two FS $NF
s = s ? s FS _ : $0
}' file