in reply to Skip lines until you find a delimiter >>

Please show us what you've tried and give a sample of your data

  • Comment on Re: Skip lines until you find a delimiter >>

Replies are listed 'Best First'.
Re^2: Skip lines until you find a delimiter >>
by RohanGuddad (Initiate) on Mar 14, 2018 at 07:49 UTC
    i have file with some data like below. <"Session Date:Mar 13/2017 ":>>test", 1,2,3,4 ":>>test1", 5,6,7,8 end> i want to skip first few lines until i encounter line with ":>>" and load the first value (test) to a variable..

      What did you try and in what way did it fail to meet your expectations?

      As you are new here you may not yet have read all the FAQ and maybe not even How do I post a question effectively? or Is PM a good place to get answers for homework? It's probably a good idea to have a quick read through those now.

      There would be many literal answers to your question as posed but here's one that I do not particularly recommend and is therefore presented only for amusement as it probably isn't what you wanted anyway.

      echo '<"Session Date:Mar 13/2017 ":>>test", 1,2,3,4 ":>>test1", 5,6,7,8 end>' | perl -ne '/\x3E{2}(\w+)/&& die "Variable is $1\n";'

      You'll probably want to start with perlintro and then move on to perlrun and perlretut. Enjoy.