> For the complete documentation index, see [llms.txt](https://sh.howtocode.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sh.howtocode.dev/3.0.0.part3intro/3.5.0.0.search/3.5.2.0.find/3.5.2.3.action.md).

# find: একশন

find দিয়ে কোনো কিছু খুঁজে বের করার পর তার ওপর সরাসরি কোনো কমান্ড এপ্লাই করা যায়। এমনকি এমনকিছু একশন ডিফল্টভাবে দেওয়াও আছে:

| একশন    | কাজ                                                           |
| ------- | ------------------------------------------------------------- |
| -delete | ফাইলগুলো ডিলিট করবে। **ব্যবহারে বিশেষ সতর্কতা নিশ্চিত করুন।** |
| -ls     | ফাইলগুলো `ls -dils` কমান্ডের মত প্রিন্ট করবে।                 |
| -print  | স্ট্যান্ডার্ড আউটপুটে প্রিন্ট করবে। এটি ডিফল্টভাবে কাজ করে।   |
| -quit   | কোনো মিল পেলে সার্চ বন্ধ করবে।                                |

যদি আমরা হোমফোল্ডারের সকল .BAK একস্টেনশনওয়ালা ব্যাকআপ ফাইলগুলো ডিলিট করতে চাই তাহলে লিখতে হবে:

```
me@howtocode-pc:~$ find ~ -type f -name '*.BAK' -delete
```

শুধু `find` কমান্ডের নিজস্ব একশন না, আমরাও একশন যোগ করতে পারি এভাবে:

```
me@howtocode-pc:~$ type f -name "*.iso" \( -size +300M \) -and \( -size -700M \) -exec ls -l '{}' ';'
-rw-rw-r-- 1 nishadsingha nishadsingha 729808896 Feb  8 21:31 /home/nishadsingha/lubuntu-14.04.1-desktop-i386.iso
-rw-rw-r-- 1 nishadsingha nishadsingha 411041792 Mar 29 15:39 /home/nishadsingha/archbang-150328-i686.iso
-rw-rw-r-- 1 nishadsingha nishadsingha 478935040 Mar  9 13:40 /home/nishadsingha/Porteus-KDE4-v3.1-i486.iso
-rw-rw-r-- 1 nishadsingha nishadsingha 665845760 Feb  8 21:25 /home/nishadsingha/debian-7.7.0-amd64-CD-1.iso
```

আমরা কমান্ডের শেষে `-exec ls -l '{}' ';'` ব্যবহার করেছি। আসুন এর অংশগুলো দেখি:

* **-exec**: এটির মাধ্যমে আমরা কমান্ড এপ্লাই করবো। ইন্টারএকটিভলি কাজ করতে `-ok` ব্যবহার করতে হবে।
* **ls -l**: আমরা যে কমান্ডটি সার্চ রেজাল্টের উপর এপ্লাই করতে চেয়েছি।
* **'{}'**: এটি দিয়ে কারেন্ট পাথনেম বোঝায়।
* **';'**: কমান্ডের সমাপ্তি বোঝায়। এক্ষেত্রে প্রত্যেক সার্চ রেজাল্টের জন্য একবার করে `ls -l` কমান্ডটি দিবে। তবে আমরা যদি **+** ব্যবহার করি আগে সমস্ত সার্চরেজাল্ট থেকে একটি লিস্ট তৈরী করবে, তার ওপর কমান্ডটি এক্সিকিউট করবে।

## xargs

একশন যা করে তা আমরা `xargs` দিয়ে আরো সহজে করতে পারি। `xargs` এর কাজ হল স্ট্যান্ডার্ড আউটপুট থেকে তথ্য নিয়ে অন্য কমান্ডের জন্য ইনপুট তৈরী করা। অনেকসময় ফাইলের নামের ভিতরেই স্পেস থাকে। সেক্ষেত্রে আমরা `find` এর সাথে `-print0` এবং `xargs` এর সাথে `--null` অপশন ব্যবহার করবো। সুতরাং পূর্ববর্তী কমান্ডটি আমরা এভাবে লিখতে পারি:

```
me@howtocode-pc:~$ find ~ -type f -name "*.iso" \( -size +300M \) -and \( -size -700M \) -print0 | xargs --null ls -l
-rw-rw-r-- 1 nishadsingha nishadsingha 411041792 Mar 29 15:39 /home/nishadsingha/archbang-150328-i686.iso
-rw-rw-r-- 1 nishadsingha nishadsingha 665845760 Feb  8 21:25 /home/nishadsingha/debian-7.7.0-amd64-CD-1.iso
-rw-rw-r-- 1 nishadsingha nishadsingha 729808896 Feb  8 21:31 /home/nishadsingha/lubuntu-14.04.1-desktop-i386.iso
-rw-rw-r-- 1 nishadsingha nishadsingha 478935040 Mar  9 13:40 /home/nishadsingha/Porteus-KDE4-v3.1-i486.iso
```
