Skip to content

Instantly share code, notes, and snippets.

@iammapping
Created June 9, 2020 15:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iammapping/2d4cef97e5366b42aa847e6b796e3da3 to your computer and use it in GitHub Desktop.
Save iammapping/2d4cef97e5366b42aa847e6b796e3da3 to your computer and use it in GitHub Desktop.
cat head and tail
#!/usr/bin/awk -f
BEGIN {
line = 0
split_line_outed = 0;
arr[1] = "";
}
{
line = NR
arr[NR] = $0
}
END {
for (i = 1; i < line + 1; i++) {
if (i > n && split_line_outed == 0 && line >= 2 * n + 1) {
split_line_outed = 1;
print "============";
}
if (i <= n || i >= line - n + 1) {
print arr[i];
}
}
}
@iammapping
Copy link
Author

find /your_dir -type f -exec cat {} ; | catht -v n=2000 | pbcopy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment