Bash: removing several patterns from file names
1
vote
1
answer
615
views
Normally, looping over the files I use
basename
to extract the name of the file as a separate variable:
# remove .pdb extension from filename in new variable and print name of the file without it
for pdb in "${storage}"/complex*.pdb ; do
pdb_name=$(basename "$pdb" .pdb)
echo this is "$pdb_name" without its extension!
done
How could I remove several patterns from each file using the same basename
expression? For instance, in addition to ".pdb" I would like to omit also "complex", which is always present at the beginning of each file (here I used it as a pattern to recognize file in for LOOP).
Asked by user3470313
(213 rep)
Oct 21, 2020, 08:29 AM
Last activity: Oct 21, 2020, 10:31 AM
Last activity: Oct 21, 2020, 10:31 AM