# Skip lines in a log file

**URL:** <https://discuss.elastic.co/t/skip-lines-in-a-log-file/115276>\
**Category:** Logstash\
**Created:** [January 12, 2018, 10:50am UTC](https://discuss.elastic.co/t/skip-lines-in-a-log-file/115276 "2018-01-12T10:50:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cilzzz](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cilzzz](https://discuss.elastic.co/u/cilzzz)\
**Post date:** [January 12, 2018, 10:50am UTC](https://discuss.elastic.co/t/skip-lines-in-a-log-file/115276/1 "2018-01-12T10:50:18Z")

</div>

Hey

i have a log file like this:

```
Job Name : save_start_config-sftp Job Status: Success (0)
Schedule Name : daily_save_start_config User Name : mfservice
Completion time: Mon Jan 8 06:00:21 2018
--------------------------------- Job Output ---------------------------------
`run-script bootflash:/save_start_config_sftp.vsh`
`copy running-config startup-config
`

[#] 1%
[#] 2%
[##] 3%
[##] 4%
[###] 5%
[###] 6%
[###] 7%
[####] 8%
[#####] 10%
[#####] 11%
[#####] 12%
[######] 13%
[######] 14%
[#######] 15%
[#######] 16%
[#######] 17%
[########] 18%
[#########] 20%
[#########] 21%
[#########] 22%
[##########] 23%
[##########] 24%
[###########] 25%
[###########] 26%
[###########] 27%
[############] 28%
[#############] 30%
[#############] 31%
[#############] 32%
[##############] 33%
[##############] 34%
[###############] 35%
[###############] 36%
[###############] 37%
[################] 38%
[#################] 40%
[#################] 41%
[#################] 42%
[##################] 43%
[##################] 44%
[###################] 45%
[###################] 46%
[###################] 47%
[####################] 48%
[#####################] 50%
[#####################] 51%
[#####################] 52%
[######################] 53%
[######################] 54%
[#######################] 55%
[#######################] 56%
[#######################] 57%
[########################] 58%
[#########################] 60%
[#########################] 61%
[#########################] 62%
[##########################] 63%
[##########################] 64%
[###########################] 65%
[###########################] 66%
[###########################] 67%
[############################] 68%
[#############################] 70%
[#############################] 71%
[#############################] 72%
[##############################] 73%
[##############################] 74%
[###############################] 75%
[###############################] 76%
[###############################] 77%
[################################] 78%
[#################################] 80%
[#################################] 81%
[#################################] 82%
[##################################] 83%
[##################################] 84%
[###################################] 85%
[###################################] 86%
[###################################] 87%
[####################################] 88%
[#####################################] 90%
[#####################################] 91%
[#####################################] 92%
[######################################] 93%
[######################################] 94%
[#######################################] 95%
[#######################################] 96%
[#######################################] 97%
[########################################] 98%
[########################################] 100%
Copy complete.
`copy startup-config sftp://service-mainframe@10.155.158.186./home/service-mainframe/conf_WWF_CH_C_2018-01-08-06.00.16.txt
`
Connected to 10.155.158.186.
sftp> 
sftp> put /var/tmp/vsh/SANMF-DAL-A-startup-config /home/service-mainframe/conf_WWF_CH_C_2018-01-08-06.00.16.txt 
Uploading /var/tmp/vsh/SANMF-DAL-A-startup-config to /home/service-mainframe/conf_WWF_CH_C_2018-01-08-06.00.16.txt
sftp> exit 

Copy complete.
==============================================================================
Job Name : save_start_config-sftp Job Status: Success (0)
Schedule Name : daily_save_start_config User Name : mfservice
Completion time: Tue Jan 9 06:00:20 2018
--------------------------------- Job Output ---------------------------------
`run-script bootflash:/save_start_config_sftp.vsh`
`copy running-config startup-config
`

[#] 1%

```

i need to drop all lines and keep this part :

```
`copy startup-config sftp://service-mainframe@10.155.158.186./home/service-mainframe/conf_WWF_CH_C_2018-01-08-06.00.16.txt
`
Connected to 10.155.158.186.
sftp> 
sftp> put /var/tmp/vsh/SANMF-DAL-A-startup-config /home/service-mainframe/conf_WWF_CH_C_2018-01-08-06.00.16.txt 
Uploading /var/tmp/vsh/SANMF-DAL-A-startup-config to /home/service-mainframe/conf_WWF_CH_C_2018-01-08-06.00.16.txt
sftp> exit 

Copy complete.

```

any idea please!

than you!

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 16, 2018, 4:34pm UTC](https://discuss.elastic.co/t/skip-lines-in-a-log-file/115276/2 "2018-01-16T16:34:45Z")

</div>

Please don't repeatedly post the same question.

Can't you wrap a drop filter in a conditional so that you either choose to include only the lines matching a particular regexp or to exclude those matching a particular regexp?

---

<div class="post-metadata">

**Author:** ![cilzzz](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cilzzz](https://discuss.elastic.co/u/cilzzz)\
**Post date:** [January 17, 2018, 9:07am UTC](https://discuss.elastic.co/t/skip-lines-in-a-log-file/115276/3 "2018-01-17T09:07:05Z")

</div>

ok i am new in logstash i've tried this and it worked

```
if [message] !~ /^(Copy complete|`copy startup-config sftp:|Connected to|sftp> put|Uploading|sftp> exit)/{
drop {} }

```

i have one question please after i droped the line that i don't need

i've got results in kibana each line is a message:

```
copy startup-config sftp://mfservice@10.240.xxx.xx/home/mfservice/conf_SANMF-DAL-A_2018-01-09-06.00.15.txt
Connected to 10.240.xxx.xx
sftp> 
sftp> put /var/tmp/vsh/SANMF-DAL-A-startup-config /home/mfservice/conf_SANMF-DAL-A_2018-01-09-06.00.15.txt 
Uploading /var/tmp/vsh/SANMF-DAL-A-startup-config to /home/mfservice/conf_SANMF-DAL-A_2018-01-09-06.00.15.txt
sftp> exit  
Copy complete.

```

i need now to make all this into one message so i can apply my grok filter  
i 've tried this :

```
 multiline {

    pattern => "\n$"
    what => "next"

  }

```

it showed the same results as before plus the result that i want !

do you have an idea please ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 14, 2018, 9:07am UTC](https://discuss.elastic.co/t/skip-lines-in-a-log-file/115276/4 "2018-02-14T09:07:06Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
