Hi,
I have a issue, I need to loop through a comma delimited file and check for the length which exceeds specified length , if Yes truncate the string.
But my problem is , I do not have to check for all the fields and the field lenght is not same for all the fields.
For ex:
Say my line
ahjdh,dfhkajhdf,adhklf,eiour
say I need to check length only for 2nd and 4th and max length for 2nd is 6
My goal is deceptively simple (at least to me).
i have 3 files as below:
Code:
[test1][test2][test3]
i want to print 1st,2nd,5th and 10th filed of 1st to 5th lines from each files into a line of an output file, so the result would be:
[output]:
Code:
{line1}(field 1 of line 1 from file 1)(field 2 of line 1 from file 1)(field 5 of line 1 from file 1)(field 10 of line 1 from file 1)...(field 10 of line 5 from file 1)
{line2}(field 1
I need help to extract coincidences from a file.
I capture network traffic with tcpdump command
tcpdump -Xvv -i eth0 > captureFile.txt
Given any field of IP headers, TCP and Ethernet specify all values found in the captured traffic and count how many times that value for that field.
I want to make a script to read row by row and find its length. If the length is less than my required length then i hav to append spaces to that paritucular row.
Hi,
Is there any short method to print from a particular field till another filed using awk?
Example File:
Code:
File1
====
1|2|acv|vbc|......|100|342
2|3|afg|nhj|.......|100|346
Expected output:
[code]
File2
====
acv|vbc|.....|100
afg|nhj|.....|100
[code]
In the above example, let say I have 101 fields, I have print line only from 3 field to 100 field.
Is
Code:
awk '{print $3FS
Hi,
I have a file of the following format:
Code:
AV 103
AV 104
AV 105
AV 308
AV 517
BN 210
BN 211
BN 212
BN 218
and the desired output is :
Code:
AV 103-105 3
AV 308 1
AV 517 1
BN 210-212 3
BN 218 1
In the output file the first field is the string only.
I am trying to trim spaces for the fixed width file starting from location 129 and of length 20.
I am expecting only around 40 records that will have length greater than 9. But i am getting around 4000 records.
Please help me correct the following.
Code:
nawk '{if (a=length(gsub(/ */,"",substr($0,129,20)))>9); print $a }' testfile |wc -l
Dear Friends,
I have file a.txt
Code:
1|2|3|4|5|6|7|8
a|b|c|d|e|f|g|h
i am using the below code to swap the fields in file
Code:
awk -F\| '{print $5,$1,$2,$3,$4,$6,$7,$8}' OFS=\| a.txt > output.txt
output.txt
Code:
5|1|2|3|4|6|7|8
e|a|b|c|d|f|g|h
The above command is working fine.