Problem: I need to delete files and folder from a directory full of files and folders with exceptions of files that I don't want to be deleted.
First attempt:
rm -r !(c_50.tbl sim.sh pam.prp PROINT spy.inp s.bak sr.ccmg sr.drp s.echo s.mdl st.prob SUB.bsub ufile)
Unfortunately, this command delete everything inside the directory
Note: In brackets the files that I don't want delete. ufile
is a folder.
!()
you want to separate patterns (i.e. filenames) with|
not space. See gnu.org/software/bash/manual/bashref.html#Pattern-Matching and read about "pattern-list". – glenn jackman Jan 22 '19 at 16:29