# Find + Exec

Change html files to mode 644:

```bash
find /usr/local -name "*.html"-type f -exec chmod 644 {} \;
```

Change cgi files to mode 755:

```bash
find htdocs cgi-bin -name "*.cgi"-type f -exec chmod 755 {} \;
```

Run ls command on files found:

```bash
find .-name "*.pl"-exec ls -ld {} \;
```

Find and tar:

```bash
find .-type f -name "*.java"|xargs tar cvf myfile.tar
```

```bash
find .-type f -name "*.java"|xargs tar rvf myfile.tar
```

Find and Delete:

```bash
find .-type f -name "Foo*"-exec rm {} \;
```

```bash
find .-type d -name CVS -exec rm -r {} \;
```

Find and Copy:

```bash
find .-type f -name "*.mp3"-exec cp {} /tmp/MusicFiles \;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.shellspells.net/linux/file-ops/search/find-+-exec.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
