AllSetup
  • Introduction
  • Docker
  • Common commands
    • Various S3 utilities
    • Mac stuff
  • Mac stuff
  • Dockerfile examples
  • Docker GPU
  • TensorFlow
  • tensorFlow on iOS
  • Jupyter
  • iOS
  • SSD work
  • SSD using Inception
  • Object Detection
  • Docker GPU
  • TitBits
  • MySQL
  • FAIR Multipathnet
  • Git and GitFlow
  • Java Scala Mongo Installation
  • Devops
  • scratchpad
  • GCP Production
  • GStreamer
  • bash
  • Scala
  • Unix commands
  • Publish-Subscribe
  • Sensor-project
  • Flutter-project
Powered by GitBook
On this page
  • AWK
  • Find and delete

Was this helpful?

Unix commands

PreviousScalaNextPublish-Subscribe

Last updated 5 years ago

Was this helpful?

AWK

# To awk over multiple delimiters - here delimiters are ' (which is escaped using a \ and :
  grep imageNames ~/Downloads/DriscollsGTdata-2019-05-08-Full.txt | awk -F[\':] '{print $3, $9}'

Find and delete

Ref:

To find all zero size files, simply use:

find ./ -type f -size 0
or:

find ./ -type f -empty

To find and then delete all zero size files, there are variants you can use:

find ./ -type f -size 0 -exec rm -f {} \;
find ./ -type f -size 0 | xargs rm -f
find ./ -type f -size 0 -delete
The xargs will cause all the filenames to be sent as arguments to the rm -f commands. This will save processes that are forked everytime -exec rm -f is run. But is fails with spaces etc in file names.

The -delete is the best when it is supported by the find you are using (because it avoids the overhead of executing the rm command by doing the unlink() call inside find().

Empty directories
To find all empty directories, simply use:

find ./ -type d -empty
This command will find all empty directories in the current directory with subdirectories and then print the full pathname for each empty directory to the screen.

To find and then delete all empty directories, use:

find ./ -depth -type d -empty -exec rmdir {} \;
or:

find ./ -type d -empty -delete
The -delete is the best when it is supported by the find you are using.
https://mycyberuniverse.com/linux/find-and-delete-the-zero-size-files-and-empty-directories.html