Skip to content

Tag: linux

Read a file that’s constantly updated (C++)

Let me start with saying that I’m around 3 days old in C++. Ok to the main question, I have a file that spans multiple lines, and I’m trying to print one specific line repeatedly, which is subject to change arbitrarily by some other process. Example file : I’m trying to print the middle line…

extract substrings starting with same pattern in a file

I have a fileA.txt which contains strings: I would like to extract all the substring which start with RS Output: I tried something like this: However I only get the first string RS0247 printed out when I do echo Answer Given the three sample lines pasted above in the file f… Assuming a fixed format: Ass…

Name check match pattern

I need help as to why code B is producing a different result The code below (CODE A) produces the correct output (match) However, the below (CODE B) produces a wrong output (no match) Answer To check a regex in an if-statement you’ll need to use =~ instead off ==; Both will match as expected. Try it onl…