This question already has an answer here:
I have the a series of markdown files in the working directory:
$ ls *.md csv_reader.md egrep.md find.md found_pdfs.md osPathSep_help.md readme.md smtplib_help.md today.md
I want to remove them except "today.md"
#!/usr/local/bin/bash for i in ./*.md ; do if [[ $i != "today.md" ]]; then echo $i fi done
Run it and get
$ bash bash/remove_files.sh ./csv_reader.md ./egrep.md ./find.md ./found_pdfs.md ./osPathSep_help.md ./readme.md ./smtplib_help.md ./today.md
Nonetheless, the structured commands are not handy in the command line, how could I accomplish such a task with shorter commands