Я читал об этом в Объединение двух команд sed , https://unix.stackexchange.com/questions/407937/combine-two-sed-commands, объединение двух команд sed и другие вопросы, но до сих пор не понимаю, какобъединить 2 команды sed.
Вот мой пример файла (file.txt).
10/8/18
6:54:42.000 PM
Oct 8 19:54:42 x.x.x.x 231 <134> 2018-10-08T18:54:42Z Server_Name: 2018-10-08 18:54:42 - Server_Name - [127.0.0.1] System()[] - User Accounts modified. Removed username JohnDoe from authentication server RSA.
host = Server_Name
source = /opt/x.x.x.x-20181008.log
sourcetype = sslvpn
10/8/18
6:47:33.000 PM
Oct 8 19:47:33 x.x.x.x 266 <134> 2018-10-08T18:47:33Z Server_Name: 2018-10-08 18:47:33 - Server_Name - [y.y.y.y] JohnDoe - Closed connection to z.z.z.z after 6547 seconds, with 5526448 bytes read and 15634007 bytes written
host = Server_Name
source = /opt/x.x.x.x-20181008.log
sourcetype = sslvpn
10/8/18
6:47:33.000 PM
Oct 8 19:47:33 x.x.x.x 229 <134> 2018-10-08T18:47:33Z Server_Name: 2018-10-08 18:47:33 - Server_Name - [y.y.y.y] JohnDoe - VPN Tunneling: Session ended for user with IPv4 address z.z.z.z
host = Server_Name
source = /opt/x.x.x.x-20181008.log
sourcetype = sslvpn
10/8/18
6:47:33.000 PM
Oct 8 19:47:33 x.x.x.x 204 <134> 2018-10-08T18:47:33Z Server_Name: 2018-10-08 18:47:33 - Server_Name - [y.y.y.y] JohnDoe - Logout from y.y.y.y (session:abc)
host = Server_Name
source = /opt/x.x.x.x-20181008.log
sourcetype = sslvpn
Желаемый вывод
Oct 8 19:54:42 x.x.x.x 231 <134> 2018-10-08T18:54:42Z Server_Name: 2018-10-08 18:54:42 - Server_Name - [127.0.0.1] System()[] - User Accounts modified. Removed username JohnDoe from authe
ntication server RSA.
Oct 8 19:47:33 x.x.x.x 266 <134> 2018-10-08T18:47:33Z Server_Name: 2018-10-08 18:47:33 - Server_Name - [y.y.y.y] JohnDoe - Closed connection to z.z.z.z after 6547 seconds, with 5526448 by
tes read and 15634007 bytes written
Oct 8 19:47:33 x.x.x.x 229 <134> 2018-10-08T18:47:33Z Server_Name: 2018-10-08 18:47:33 - Server_Name - [y.y.y.y] JohnDoe - VPN Tunneling: Session ended for user with IPv4 address z.z.z.z
Oct 8 19:47:33 x.x.x.x 204 <134> 2018-10-08T18:47:33Z Server_Name: 2018-10-08 18:47:33 - Server_Name - [y.y.y.y] JohnDoe - Logout from y.y.y.y (session:abc)
То, что я сделал (2 команды sed) для получения вывода, было
sed -n '/[0-9]\/[0-9]\//,+1!p' file.txt > file2.txt
sed -n '/host =/,+3!p' file2.txt
Основываясь на ответе на другие вопросы, решением была точка с запятой, но я просто не уверен, как ее использовать,Вот моя попытка использовать точку с запятой, которая вообще не работала.
sed -n '/[0-9]\/[0-9]\//,+1!p;/host =/,+3!p' file.txt
Пожалуйста, сообщите