简体   繁体   中英

How to grep text from a specific line?

I need to grep text from a specific line.

I don't need to grep from the whole file, but only one line.

CATS_COLOR_TEST=$(grep FF0000 "${STYLE_FILENAME}")

how to specify a line, for example, I need 31.

您可以像这样使用单个awk

CATS_COLOR_TEST=$(awk 'NR == 31 && /FF0000/' "$STYLE_FILENAME")

您可以像这样使用 head 和 tail:

head -n 31 file_to_grep | tail -n 1

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