I want to put target files as input to a command.
My directory currently has mixed target files with weight files. (simplified)
(base) directory % ls
file_015_apple.txt
file_015_orange.txt
file_016_apple.txt
file_016_orange.txt
file_017_apple.txt
file_017_apple.weight.txt
file_017_orange.txt
file_017_orange.weight.txt
...
I only want to return target files, but without using grep.
Because it's not readable to the command.
ls -l file* | grep -v "weight"
I tried many things only to fail.
1044 ls file*.txt ! -name "*weight*"
1045 ls file*.txt ! -name *weight*
1046 ls file*.txt ^*weight*
1049 ls file*(^weight).txt
1055 ls file*.txt/^*weight.txt
If I put all files then an error occurs.
% command file_*.txt
*Error*: field_017_apple.weight.weight.txt not found
Any solutions?
CodePudding user response:
Try the following:
ls *~*weight.txt
You might need to enable extended glob options:
setopt extendedglob