I have many strings like this
i=./M1/CustomersList/HTP/Boston/FCT/output_GetCaseList_abs.txt
I need to extract the M1 code and the FCT but I am unable to do so, likely due to the regular expressions. FCT I can do with echo ${i:30:3}, but for M1 nothing seems to work - my last try was grep -oP '.*\K(?<=.\/)\w+(?=\/Cus)' $i ;
The length of the string can vary (but it always starts with /F) and /M1/ is always in the same position
Hope somebody can help. Thanks!
always starts with /Fbut you don't say that no other section can also start with/F, e.g. if your input was about a customer inFlagstaffinstead ofBoston. You imply thatFCTcan appear in different positions but maybe not. 1 sample input line isn't enough for us to guess the general form of your input and test a potential solution. Please provide about 4 or 5 diverse input lines and the expected output given that input so we can help you solve your real problem as opposed to just producing the expected output for that 1 line of sample input