On my Linux machine, I want to remove the directories containing specific words that I stored in a parameter ($LIB_TO_REMOVE). But, when I used the wild card and parameter expansion (first ls
to check), the shell does not interpret *
as the wild card. Any suggestions? I'm expecting ls *${LIB_TO_REMOVE}*
to list the first 3 directories.
$ ls
NG-23827_01_AD_02_BI_LS_01_F4_lib390563_6741_1_quant
NG-23827_01_AD_04_BI_LS_01_A7_lib390582_6741_1_quant
NG-23827_01_AD_04_BI_NL_02_B7_lib390583_6737_1_quant
NG-23827_01_AD_05_BI_LS_01_A11_lib390614_6741_2_quant
NG-23827_01_AD_05_BI_LS_02_A8_lib390590_6741_1_quant
NG-23827_01_AD_05_BI_NL_01_C9_lib390600_6741_1_quant
NG-23827_01_AD_06_BI_NL_02_E3_lib390554_6741_1_quant
NG-23827_01_AD_07_BI_LS_02_G5_lib390572_6741_1_quant
NG-23827_01_AD_07_BI_NL_02_F1_lib390539_6751_1_quant
NG-23827_01_AD_08_BI_LS_02_G8_lib390596_6741_1_quant
$ echo $LIB_TO_REMOVE
lib390563 lib390582 lib390583
$ ls *${LIB_TO_REMOVE}*
ls: cannot access *lib390563: No such file or directory
ls: cannot access lib390582: No such file or directory
ls: cannot access lib390583*: No such file or directory