Skip to content

How to grep a string in a program?

Description: The str_buf_to_grep is given in any way, which might be the content of a text file, and might be very long and complex, even contains special characters, such as |, “, etc. I want to use the grep command to find matched lines, and the patterns might be very complex. How should I implement i…

Variable passed through environment not available in script

I’m trying to write an if/elif/else statement where if a variable equals “Full” it will cat a file and if the same variable equals “Quick” it will read a different, smaller file. The variable is being set outside of the script and is being exported by export var1=Quick I have Whe…

Getting linux system UUID which changes after reboot

I’m looking for a linux system session id which is constant over the full runtime of the linux session (as long as uptime is increasing). After each reboot, it should be reset to another (random) value, probably formatted as a uuid. I need this for logging in a global context, where I need to know if tw…

How to use awk regex sort by query string value?

I have a log file with example row: The 7th column of each row looks like this: Output is arranged according to the number of lines in decreasing order containing unique values of t. Desired OUTPUT: I am using awk but it is not giving desired output: It outputs all columns after 7th which is not required. Wha…

Dynamically find the address at which the kernel is loaded

I’d like to be able to programmatically find out the address at which the linux kernel is loaded. If there are tools out there that already do that, I’d be willing to use them. However, inspecting the PARAMS_PHYS field in the .config during the kernel build is not an option. How could I go about d…