Artificial intelligent assistant

how to grep both files , but exclude other files We want to search string by grep to both files: The files are /confluent/logs/server.log /confluent/logs/server.log.1 But we not want to match the other files as /confluent/logs/server.log.2 /confluent/logs/server.log.3 etc So instead to do double grep as grep log.retention.bytes /confluent/logs/server.log grep log.retention.bytes /confluent/logs/server.log.1 we want to find the match of `log.retention.bytes` on both files on the same time we try to do grep log.retention.bytes /opt/mcspace/confluent/logs/server.log.*[1] but this is wrong

grep log.retention.bytes server.log{,.1}


In order to keep log entries (appended) in chronological order, you might want to reverse the order of files:


grep log.retention.bytes server.log{.1,}


which is of course equivalent to:


grep log.retention.bytes server.log.1 server.log


as the brace expansion is done by the shell before executing the `grep` command.

Moreover, with `zsh` shell you can easily automatically glob for the _last N files matching a pattern_ with:


grep log.retention.bytes server.log*(Om[-2,-1])


where `Om` means _order by mtime descending_ and `[-2,-1]` fetches 2 last rows. This trick is worth remembering if you watch to search more files and do not want to type them manually.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 82ac159a064769179ad548206f36c45e