Skip to content

Instantly share code, notes, and snippets.

@AlexAtkinson
Last active May 31, 2023 18:14
Show Gist options
  • Save AlexAtkinson/007a20577a0115c3647cbb3cdc0185b5 to your computer and use it in GitHub Desktop.
Save AlexAtkinson/007a20577a0115c3647cbb3cdc0185b5 to your computer and use it in GitHub Desktop.

Filesystem CLI Tips

Watch the following process

Open a terminal and run the following to observe the commands interaction with the fs as they happen.

watch tree top/

Make a multi-level directory structure, with kitties and puppies

mkdir -p top/{sub1,sub2,sub3}/{basement1,basement2,basement3}
touch top/{kitty,puppy}
touch top/{sub1,sub2,sub3}/{kitty,puppy}
touch top/{sub1,sub2,sub3}/{basement1,basement2,basement3}/{kitty,puppy}

Delete all the puppies from subdirs and below

find top/*/ -name puppy -type f -delete
# Or all the puppies and kitties
find top/*/ \( -name puppy -o -name kitty \) -type f -delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment