Skip to main content

File tools: reflink, copy, remove, mkfile, fileblocks, filestat, filesize

Project description

Remove

  • removes files
  • prints out filepath
  • logs filepath to syslog/sqlite

Motivation

  • being able to clean up folders deep inside tree, like: remove **/node_nodules
  • have some persistent logging on what being removed: in journald/syslog and in sqlite database
  • get list of files to remove: from file
  • get list of files to remove: from command

Alternative: rm -rf **/node_nodules

  • Yes
  • However we would not see what entries being removed

Alternative: rm -rfv **/node_nodules

  • Yes
  • But rm would log each file (inside node_modules) in this case.
  • For a large node_modules - the output is overwhelming. I just need to see which node_modules being removed and keep the output log readable.

Alternative:find and xargs

  • Yes
  • But we will end up with rather longer command for a trivial task

Alternative: find . -type d -name node_modules -prune -print -exec rm -fr {} \;

  • Yes, it does work!
  • Again, explaining commands like this would take some effort.
  • Or, running commands like this, without fully understanding it - is a risky habit

Example

pip install ngm-remove

cd projects

remove **/node_nodules

journalctl -t remove -r

Use in scripts

  • In scripts, you might need to use shopt -s globstar to enable ** globs
shopt -s globstar # feature available since bash 4.0, released in 2009
remove **/node_modules

Remove files of certain type

find . -type f -exec file {} \; | grep -i --color=never avif > files.txt
remove --input files.txt

Options

remove file1 file2              # Remove file1 and file2
remove --help                   # Show help
remove --version                # Show version
remove --input list.txt         # Get paths from list.txt and remove those
remove --cmd 'cat list.txt'     # Get paths from running command and remove those

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ngm_remove-0.0.12.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ngm_remove-0.0.12-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file ngm_remove-0.0.12.tar.gz.

File metadata

  • Download URL: ngm_remove-0.0.12.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for ngm_remove-0.0.12.tar.gz
Algorithm Hash digest
SHA256 12a18ecbea633fcfe57408c026599b73a6e1a1e33154892ba75a218cc31f4a84
MD5 ca0153563106641f41ae20c76c26fbbd
BLAKE2b-256 2da9b61b32aefbbe6d3e5b8f7c21b50846ba2e56b3e699ff6dd5fc77e7ab7851

See more details on using hashes here.

File details

Details for the file ngm_remove-0.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for ngm_remove-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 8b612d92eadb62547f72df209219f03f47902293da51a8431fa552176b0f2aff
MD5 2f833ad6433782971770a0974eb199f2
BLAKE2b-256 3bae277210a85a049573e957839947164073ebba472b4ae5223c30cc7e274c47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page