Skip to content

Instantly share code, notes, and snippets.

@behroozam
Created July 23, 2017 13:03
Show Gist options
  • Save behroozam/3d24365d6ca05247f62d6187438a10a6 to your computer and use it in GitHub Desktop.
Save behroozam/3d24365d6ca05247f62d6187438a10a6 to your computer and use it in GitHub Desktop.
how to split huge text file with awk flag
#when you have no space left on your server and your link is weak you hace no choice to remove or compress files . of course you can use awk in normal way but somtimes you log or text file contain messy things and its hard to select all pattern between start of file and end
# i use awk flag(on and off) but in normal timestamp(clear with no messy things) you can use split option to extract log
#!/bin/bash
awk '/2017-03-01/{flag=1}flag;/2017-04-01/{flag=0}' huge.log | gzip > 2017-03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment