Skip to content

Instantly share code, notes, and snippets.

@tcpdump-examples
Created December 22, 2022 13:20
Show Gist options
  • Save tcpdump-examples/693ed4352999c3ba13e38c0728c482a4 to your computer and use it in GitHub Desktop.
Save tcpdump-examples/693ed4352999c3ba13e38c0728c482a4 to your computer and use it in GitHub Desktop.

Revisions

  1. tcpdump-examples created this gist Dec 22, 2022.
    10 changes: 10 additions & 0 deletions find-file-by-name.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    find command:https://www.howtouselinux.com/post/find-file-by-name-in-linux
    # Use find command, find all *.txt files but ignore foo.txt
    find . -type f \( -iname "*.txt" ! -iname "foo.txt" \)
    # To delete file add -delete or -exec your-delete-command-here option.
    find . -type f \( -iname "*.txt" ! -iname "foo.txt" \) -delete
    # To select folder or dirs use -type d, in this example, find all folders and ignore foo and bar folder :
    find . -type d \( ! -iname "foo" ! -iname "bar" \)
    # To delete folders except foo and bar
    find . -type d \( ! -iname "foo" ! -iname "bar" \) -execdir rm -rfv {} +
    # Be careful while deleting files and dirs.