i need a shell which reads the parameter file and search the string in c1.txt once the string is found it should print those lines to an output file .
but a trick is here .. the string should print lines which start from "cool " and should print those lines but the script should stop before another cool is found
BETWEEN=false
while read N
do
case "$N" in
cool:* )
if $BETWEEN
then
BETWEEN=false
;;
else
BETWEEN=true
;;
fi
;;
* )
if $BETWEEN
then
echo "$N"
fi
;;
esac
done <file1.txt
it would be great if you would explain this code .. since if i am trying to add more lines in b.txt this script is not functioning well ,, Please give a suggestion on this .. Thanks
awk '
NR==FNR { # First file (keys)
keys["cool:" $0]++; # Memorize keys for second file
next; # Next record
}
/^cool:/ { # Record start with "cool:"
display = ($0 in keys ? 1 : 0); # If memorized key display block (1)
}
display # Display line if block must be displayed
' b a
Thanks a lot .. it worked .. but when i tried to change the search word to someother word and the lines are not the same which i had earlier
there are no errors but also it didn't produce any output
Just need to search a string(word) which would read from a param file (b)
and prints all the lines in an output from a and stops printing the line till another search string is wound
the above script worked fine . but when i try to change the a file and b file of my criteria it didn't work
any help on this .. Thanks once again !!! waiting for a reply