unix - echoing specific files, excluding some characters -
i have folder few files, these 3:
vmware-diskmanager vmware-disklib.tar.gz vmware-disklib-distrib if want echo both files without .tar.gz extension, can use
# echo v* but let's have file
vmware-disklib then use
# echo [vv]* to 4 files, can complete command line says "don't show files dot in it"?
with bash
if use bash, see man bash, expansion > pathname expansion > pattern matching:
if
extglobshell option enabled usingshoptbuiltin, several extended pattern matching operators recognized.
(this option seems default.) in particular can use:
!(pattern-list):
matches except 1 of given patterns
so in case work:
echo [vv]!(*.*) with find
i use zsh instead of bash , not work. have not checked wether there equivalent syntax zsh, go solution find:
find . -maxdepth 1 -iregex './v[^.]*' -exec echo -n "{} " \; where:
.directory search-maxdepth 1limits search current directory (no recursion)-iregex './v[^.]*'applies case-insensitive regex whole path of files in current directory-exec echo -n "{}"indicates echo file name (the name replace{}placeholder) without linebreak\;needed end-execcommand.
it should print name of files ./ @ beginning , without linebreak @ end. on plus side, can use regex.
Comments
Post a Comment