Skip to content

Instantly share code, notes, and snippets.

@rocketgeek
Created September 3, 2022 14:42
Show Gist options
  • Save rocketgeek/bc7310a888615aa51d07f6aa54ccab34 to your computer and use it in GitHub Desktop.
Save rocketgeek/bc7310a888615aa51d07f6aa54ccab34 to your computer and use it in GitHub Desktop.
remove all but a single file in a directory using ssh
# No dirs:
rm -- !(file.txt)
# If dirs:
rm -rf -- !(file.txt)
# If extglob is not enabled:
shopt -s extglob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment