Originally Posted by ntubski
If you have GNU split you can use the --filter option:
logcat | split -l 1000 --filter='gzip > $FILE' - /some_dir/log-
But it's quite likely Android has a smaller version of split that doesn't support that.
You're right. Android doesn't seem to support '--filter'
I've decided it's probably best to run a separate script to check the contents of "/some_dir" for anything NOT ending in .gz and zip thos files accordingly, but I'm having trouble with regex.
Let's say, in "/some_dir", files are listed as such:
..will obviously output
But I need to match everything BUT that which contains or ends in ".gz". I know I have to somehow get "negative lookahead" to work, but it doesn't seem to want to. Taking the most simplistic approach (to avoid problems with the "."), I tested a few commands like:
...all of which return "No such file or directory", including on my laptop (so as to elliminate Android as the culprit).
I understand "plenty" about matching strings with regex, just not inversely. What am I missing? I am pretty confused in the correct usage of negative and positive lookahead and I haven't found much that is either useful or easily understood.
Eventually I would like to include the "." in the pattern because as you can tell, there will eventually be a file saved as "log-gz" which would be matched against the "gz" argument.
Originally Posted by pan64
That would require some perl or similar knowledge
As far as I am aware, Android doesn't support Perl so that may be out of the question.
[edit:] Also, the script is logging the output of 'logcat' which is continuously running. Without 'split' the files saved are too large to be displayed in one text file, so zipping the file and then splitting it would be pointless because each file only would have the beginning output of 'logcat' and not the most recent. As it stands now, a file will be created and will filled up until it gets to 1000 lines and creates a new file with each new file containing the most recent data.