How to select the columns of a dataframe based on a vector of strings, matching for exact coincidence?

I have a dataframe with the followign column names: NewYork_10 NewYork_20 NewYork3_10 NewYork3_20 NewYork4_10 NewYork4_20 HongKong_10 HongKong_20 SanFrancisco_10 SanFrancisco_20 And I have a vector: list <- c("NewYork", "SanFrancisco") I want a script that creates a new dataframe, selecting those columns that have the exact same string before the underscore. In the example given above, you… Read More How to select the columns of a dataframe based on a vector of strings, matching for exact coincidence?

Linux search subdirectories and among .js .py files for a specific keyword

I am trying to search for the file/script with a specific keyword in all the sub-directories beginning from the root or home directory. My search yielded so many files, but I want to search only .js, .py types. I want to know the file name containing this matching word. grep -name ‘*.js’ -rl "matching word"… Read More Linux search subdirectories and among .js .py files for a specific keyword

Grep lines only if containing 2 specific strings

Is it possible to grep lines only if containing 2 specific strings in it? I have logs like this and I would like to grep only lines containing strings "13/Dec/2022:11" AND "GET /fr/test" access.log:site.ch 111.222.333.444 – – [13/Dec/2022:11:40:00 +0100] "GET /fr/test HTTP/1.1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" >Solution… Read More Grep lines only if containing 2 specific strings