Unix — grepping for a value at the start of a line -
as having a data below and I try to get delimited by the fourth value of each row (for 1 value :) I am doing. But as 1 value is available in the second row as well, it is issuing me as below
MSG_KENAN_KBILLDT1 sample.txt $ cat:. Mulconfield: liter, GE, GE, GE, GE, GE: MSG_KENAN_KPAYDDT1 MSG_KENAN_KBILLDT2 MSG_KENAN_KBILLDT3 MSG_KENAN_KBILLDT4 MSG_KENAN_KBILLDT5 MSG_KENAN_KBILLDT6 MSG_KENAN_KBILLDT3: mulconfield: le, GE, GE, GE: MSG_KENAN_KPAYDDT3 MSG_KENAN_KBILLDT4 MSG_KENAN_KBILLDT5 MSG_KENAN_KBILLDT6 $ $ grep MSG_KENAN_KBILLDT3 sample.txt | cut -d: -f4 MSG_KENAN_KPAYDDT1 MSG_KENAN_KBILLDT2 MSG_KENAN_KBILLDT3 MSG_KENAN_KBILLDT4 MSG_KENAN_KBILLDT5 MSG_KENAN_KBILLDT6 MSG_KENAN_KPAYDDT3 MSG_KENAN_KBILLDT4 MSG_KENAN_KBILLDT5 MSG_KENAN_KBILLDT6 $
You can also see MSG_KENAN_KBILLDT3 on the first line. I only need to have my search string in position 1 position.
But my expectation is output
MSG_KENAN_KPAYDDT3 MSG_KENAN_KBILLDT4 MSG_KENAN_KBILLDT5 MSG_KENAN_KBILLDT6
Because I value the price at the fourth position (MSG_KENAN_KBILLDT3) Want based.
Can anyone give me a solution? If you want MSG_KENAN_KBILLDT3 at the beginning of the line then say:
'The following pattern is displayed at the beginning of the line or' carat ^
occurs in the beginning.
Comments
Post a Comment