Last active
June 30, 2023 22:55
-
-
Save amtc131/54fbd211d8cefbe1dfdc7b543b3e9778 to your computer and use it in GitHub Desktop.
Files with AWK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/awk | |
# Here's an awk scrip that atttemps to set difference of two files based on their first column | |
# gawk -f Diff.awk file1.txt file2.txt | |
BEGIN{ | |
OFS=FS="\t" | |
file = ARGV[1] | |
while (getline < file) | |
Contained[$1] = $1 | |
delete ARGV[1] | |
} | |
!($1 in Contained){ | |
print $0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
awk -v filename="archivo_grande.txt" -v partsize="1000000" ' | |
BEGIN {part = 1; file = filename "_" part ".txt"; size = 0} | |
{ | |
size += length + 1; | |
if (size > partsize) { | |
close(file); | |
part++; | |
file = filename "_" part ".txt"; | |
size = 0 | |
} | |
print > file | |
} | |
END {close(file)} | |
' archivo_grande.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment