i have a file which contains alphanumeric data in every line. what i need is the data after certain pattern. the data after the pattern is not of fixed length so i need the data till the space after the pattern.
Input file:
bfdkasfbdfg khffkf lkdhfhdf pattern (datarequired data not required)
jdbfmdsfb kjsdfhfsd dfh pattern (sample jfbjdjf)
desired output file :
datarequired
sample
One approach would be to use egrep to extract the pattern and the following "word" then use sed to replace the pattern with an empty string
egrep -o 'pattern [^ ]+' infile | sed 's/pattern//'>outfile
Not sure what you after exactly from the description above but the following command will print everything after 'pattern'.
echo "bfdkasfbdfg khffkf lkdhfhdf pattern 123 this is printed"| perl -ne 'if (/pattern\s+(.*?)$/){print "${1}\n"}'
Output:
123 this is printed
Regards,
SRG