Skip to content

Instantly share code, notes, and snippets.

@vchrombie
Last active September 16, 2019 06:28
Show Gist options
  • Save vchrombie/f5bb0fa182451c536a6635647ac1c27c to your computer and use it in GitHub Desktop.
Save vchrombie/f5bb0fa182451c536a6635647ac1c27c to your computer and use it in GitHub Desktop.

Please download the pokemon zip package, from here and extract the files in the folder with name pokemon.

tree -a pokemon/
pokemon/  
├── dump.txt  
├── eevee  
│ ├── espeon  
│ │ └── README.md  
│ ├── flareon  
│ ├── leafeon  
│ └── README.md  
├── LICENSE.md  
├── pickachu  
│ ├── raichu  
│ │ └── README.md  
│ └── README.md  
├── README.md  
└── snorlax  
├── dump.txt  
└── README.md  
  
7 directories, 9 files


find

  • name
  • type
    • f - regular file
    • d - directory
find ./pokemon/ -name README.md

finds the files with the name README.md in pokemon folder

find ./pokemon/pickachu/ -name README.md

finds the files with the name README.md in pickachu folder

find ./pokemon/ -name *.md

finds the files with the file extension .md

find ./pokemon/ -name dump.txt

finds the files with the name dump.txt

find ./pokemon/ -name dump.txt -exec rm -i {} \;

deletes the files with the name dump.txt in pokemon

rm: remove regular empty file './pokemon/snorlax/dump.txt'? y

find ./pokemon/ -type f

finds all the files

find ./pokemon/ -type d

finds all the directories

find ./pokemon/ -empty

finds all the empty files and directories

find ./pokemon/ -type d -empty

finds all the empty directories

find ./pokemon/ -type f -name "*.md" -exec grep 'pokemon' {} \;

finds all the files which has "pokemon" written in any files


mkdir session
cd session

xargs

echo 'one two three' | xargs mkdir
ls

creates three folders with names one, two, three

echo 'one two three' | xargs -t rm -rf
ls

deletes the three folders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment