简体   繁体   中英

print the line after matching specific string using grep command

I want to print the complete line after matching a string

For example, I have this input:-

  www.google.com/images
  www.google.com/images/12
  www.yahoo.com/images/12
  www.bing.com/images/34
  www.google.com/images/12
  www.google.com/images/imagescols

And I want this output:-

 com/images              
 com/images/12           
 com/images/12           
 com/images/34           
 com/images/12           
 com/images/imagescols   

please suggest a way to do this using the grep command in unix.

You could try the below cut command.

cut -d. -f3 file

OR

awk -F. '{print $NF}' file

OR

grep -oE '[^.]*$' file

Example:

$ cut -d. -f3 file
com/images
com/images/12
com/images/12
com/images/34
com/images/12
com/images/imagescols

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM