I have a log file like bellow.
130023432 195047 /media/ismail/SSDWorking/book-collection/_Books/book 1.epub
130023433 195047 /media/ismail/SSDWorking/book-collection/_Books/book 2.epub
130023431 195047 /media/ismail/SSDWorking/book-collection/_Books/book 3.epub
I have a variable, var=130023432
I want to say if first word equals to $var
, then print all except the first two words.
So, in this case the output will be:
/media/ismail/SSDWorking/book-collection/_Books/book 2.epub
What I have tried so far is grep -oP "(?<=$var \d+ ).*$'"
but it gives error grep: lookbehind assertion is not fixed length
How can I achieve that?
grep -oP "$var \d+ \K.*"
works.awk -v var="$var" '$1 == var {print}' | cut -d" " -f3
also works.{print}
to{$1=$2=""; print $0}
then you will not need to pipe tocut
and it will work with any type or amount of whitespace. Also, if you have an answer that works you can post it as an answer then accept it in a day or two. Makes the question/answer easier to search for./media/....
. How can I remove that?