Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A^_B^_C
- AA^_BB^_CC
- wc -L file
- awk '
- {
- for(i=1;i<=NF;i++)
- if (length($i) == good) { continue }
- else {
- print "Row "NR" contained data more than " good" in a single field"
- next
- }
- print "Row "NR " is valid"
- }' FS='\^_' good="1" csv
- Row 1 is valid
- Row 2 contained data more than 1 in a single field
- awk -F'\^_' -v OFS=':' '
- {
- for (i=1;i<=NF;i++) {
- if (length($i) > max) {
- max = length($i)
- lineNr = NR
- line = $0
- fldNr = i
- fld = $i
- }
- }
- }
- END {
- print lineNr, line
- print fldNr, fld
- }
- ' file
- 1^_1^_1
- awk -F'\^_' '
- NR==FNR {split($0,clen,FS); next} # store the lengths
- {
- split($0,a,FS); # put the current line in an array
- for( i in a )
- { if( length(a[i]) > clen[i] ) print "["FNR","i"] = "a[i] }
- }
- ' clengths data
- [2,1] = AA
- [2,2] = BB
- [2,3] = CC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement