AWK
text/x-awk
Magic Bytes
Offset: 0
23 21 2F 62 69 6E 2F 67 61 77 6B
AWK is a domain-specific programming language developed by Alfred Aho, Peter Weinberger, and Brian Kernighan at Bell Labs during the late 1970s. This legacy format is primarily utilized for advanced text processing, data extraction, and report generation within Unix-like environments. Although these files are human-readable plain text and safe to store, they function as executable scripts that require careful evaluation before processing to mitigate potential security risks from unverified sources.
Validation Code
How to validate .awk files in Python
Python
def is_awk(file_path: str) -> bool:
"""Check if file is a valid AWK by magic bytes."""
signature = bytes([0x23, 0x21, 0x2F, 0x62, 0x69, 0x6E, 0x2F, 0x67, 0x61, 0x77, 0x6B])
with open(file_path, "rb") as f:
return f.read(11) == signature
How to validate .awk files in Node.js
Node.js
function isAWK(buffer: Buffer): boolean {
const signature = Buffer.from([0x23, 0x21, 0x2F, 0x62, 0x69, 0x6E, 0x2F, 0x67, 0x61, 0x77, 0x6B]);
return buffer.subarray(0, 11).equals(signature);
}
Go
func IsAWK(data []byte) bool {
signature := []byte{0x23, 0x21, 0x2F, 0x62, 0x69, 0x6E, 0x2F, 0x67, 0x61, 0x77, 0x6B}
if len(data) < 11 {
return false
}
return bytes.Equal(data[:11], signature)
}
API Endpoint
GET
/api/v1/awk
curl https://filesignature.org/api/v1/awk