I need to grep all strings that start with [ and finish with a certain string, e.g. apal. So all chars in between these 2 chars would be shown as well. Given an input such as:[44060]apal223reaea[55000]opoer4nr4on[95749]assad fdfdf Bhassrj sdaapald33qdq3d3da3ded[66000]dsfsldfsfldkj[77000]porpo4o4o3j3mlkfxxxx[101335]KaMMMM MMM lapa[131322]sadasds ddd apaladsdas[138133]sadasdadasddsss KMMapaldsadsadwe[150000]idhoqijdoiwjodwiejdwThe output would be something lie[44060]apal[95749]assad fdfdf Bhassrj sdaapal[101335]KaMMMM MMM lapal[131322]sadasds ddd apal[138133]sadasdadasddsss KMMapal
grep all strings that start with a certain char, and finish with another char
bash;command line;awk;sed;grep
Use:grep -o '\[.*apal' file.txtReplace file.txt with the actual filename.On the other hand, if you want to match [ at the start of the line:grep -o '^\[.*apal' file.txt