I have an large textfile that contains an unique string in the middle. What i want to do is to print everything AFTER the string by using grep.
cat textfile | grep "target_string" This highlights target_string but prints the whole file cat textfile | grep -o "target_string" This prints only target_string cat textfile | grep -o "target_string*" This prints only target_string How can i print everything after target_string and nothing before?
Strangely, the accepted answer printed out the whole line, where I just wanted all the info after the target string. This worked for me:
sed -n 's/target_string//p' filename Adapted from this post
With GNU grep, try -B0 -A999999999 or similar. A better choice might be awk:
awk '/target_string/ {seen = 1} seen {print}' If (your problem specification is slightly unclear) you don't also need to print the matching line, sed is even shorter:
sed '1,/target_string/d'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With