Posts tagged find
Copy directory structure without content.
Sep 16th
Handy command to run if you need the directory structure replicated without the content.
To demonstrate I am going to create an example directory:
mkdir /new/destination/root/
The go into the root directory you want to replicate:
cd /source/root/
and type:
find * -type d -exec mkdir /new/destination/root/\{\} \;
Argument list too long’ error
Jun 9th
If you have ever tried to run an rm and receievd the following error message:
'/bin/rm: Argument list too long'
Just run
find . -name '*'| xargs rm
I have used * for a wildcard entry but you could put anything in there
Note
Xargs is Linux command that makes passing a number of arguments to a command easier.
Linux Searching All Files For A String (Recursively)
Feb 18th
Linux Searching All Files For A String (Recursively)
You can use the grep or find command to search recursivley for a string
Basic grep command
grep -ri "STRING" .
Options
| Option | Description |
| -r | recursive |
| -i | ignore case |