want to exit after tail command in unix

12,738

You can use this sed instead to exit as soon as text is found:

sed '/text/q' <(hadoop fs -cat /input-path/*)
Share:
12,738
Mars
Author by

Mars

Updated on June 04, 2022

Comments

  • Mars
    Mars almost 2 years

    I am using shell scripts , which performs following command

    hadoop fs -cat /input-path/* | grep "text" | tail -1
    

    I want to exit after this command, so that my shell scripts will execute another command.

  • Mars
    Mars over 9 years
    it's exiting now , but grep is not working properly.
  • anubhava
    anubhava over 9 years
    Even awk '/text/{print; exit}' <(hadoop fs -cat /input-path/*) also works.