I am writing a csh script that will extract a line from a file xyz.
the xyz file contains a no. of lines of code and the line in which I am interested appears after 2-3 lines of the file.
I tried the following code
set product1 = `grep -e '<product_version_info.*/>' xyz`
I want it to be in a way so that as the script find out that line it should save that line in some variable as a string & terminate reading the file immediately ie. it should not read furthermore aftr extracting the line.
Please help !!
grep has an
-mor--max-countflag that tells it to stop after a specified number of matches. Hopefully your version of grep supports it.From the man page linked above:
As an alternative, you can always the command below to just check the first few lines (since it always occurs in the first 2-3 lines):