linux:commands:file_directory

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
linux:commands:file_directory [2024/01/22 13:34] – [ディレクトリの容量] ともやんlinux:commands:file_directory [2024/04/15 05:35] (現在) – [ファイル検索[find]] ともやん
行 2: 行 2:
  
 ===== ファイル検索[find] ===== ===== ファイル検索[find] =====
-filename.txt というファイルを / (ルートディレクトリ)配下のすべてのファイルから検索する +/ (ルートディレクトリ)配下の filename.txt というファイルをすべて検索する...🤔\\ 
-<code+<WRAP color_term
-$ find / -name filename.txt+<WRAP color_command><html><pre> 
 +<font color="#FF8700"><b>$</b></font> <font color="#26A269">find</font> <u style="text-decoration-style:single">/</u> <font color="#A347BA">-name</font> filename.txt 
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre>
 /home/tomoyan/filename.txt /home/tomoyan/filename.txt
 /home/tomoyan/Documents/filename.txt /home/tomoyan/Documents/filename.txt
-</code>+</pre></html></WRAP> 
 +</WRAP> 
 + 
 +. (カレントディレクトリ)配下の *.orig というファイルをすべて検索する...🤔\\ 
 +<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +<font color="#FF8700"><b>$</b></font> <font color="#26A269">find</font> <u style="text-decoration-style:single">.</u> <font color="#A347BA">-name</font> <font color="#12488B"><b>*</b></font>.orig <font color="#A347BA">-type</font>
 +</pre></html></WRAP> 
 +<WRAP color_result><html><pre> 
 +./kernel_b/nvidia-drm/nvidia-drm-drv.c.orig 
 +./kernel_b/nvidia/nv-acpi.c.orig 
 +./kernel_b/conftest.sh.orig 
 +./kernel/nvidia/nv-acpi.c.orig 
 +./kernel/nvidia-drm/nvidia-drm-drv.c.orig 
 +./kernel/Kbuild.orig 
 +./kernel/conftest.sh.orig 
 +</pre></html></WRAP> 
 +</WRAP> 
 + 
 +それらを削除する😱\\ 
 +<WRAP color_term> 
 +<WRAP color_command><html><pre> 
 +<font color="#FF8700"><b>$</b></font> <font color="#26A269">find</font> <u style="text-decoration-style:single">.</u> <font color="#A347BA">-name</font> <font color="#12488B"><b>*</b></font>.orig <font color="#A347BA">-type</font> f <font color="#12488B"><b>|</b></font> <font color="#26A269">xargs</font> rm <font color="#A347BA">-rf</font> 
 +</pre></html></WRAP> 
 +</WRAP>
  
 ===== 文字列を含むファイルを検索[grep] ===== ===== 文字列を含むファイルを検索[grep] =====
行 214: 行 241:
  
 ===== ディレクトリの容量 [du] ===== ===== ディレクトリの容量 [du] =====
-dir_name の容量表示\\ 
-<WRAP prewrap 100%> 
-<code> 
-$ du -h -s dir_name 
-1.6G    dir_name 
-</code> 
-</WRAP> 
- 
-dir_name 配下のサブディレクトリ毎の容量表示\\ 
-<WRAP prewrap 100%> 
-<code> 
-$ du -h -s dir_name/* 
-1.6G    dir1 
-0.2G    dir2 
-0.3G    dir3 
-</code> 
-</WRAP> 
- 
-dir_name 配下のすべてのサブディレクトリとファイル容量表示(降順, 上位50件)\\ 
-※ファイルのみの表示はできない😅\\ 
-<code> 
-$ du -kha dir_name/* --exclude={exclude_dir1,exclude_dir2,exclude_dir3} | sort -rn | head -50 
-</code> 
-find コマンドならファイルのみサイズ表示できる🤤\\ 
-<code> 
-$ find ./dir_name -ls | sort -rh -k 7 | head -50 
-$ find ./dir_name -printf "%s %M %n %u %g %b %TD %TR %p\n" | sort -hr | head -50 
-</code> 
- 
-容量の昇順ソート\\ 
-<WRAP prewrap 100%> 
-<code> 
-$ du -h -s dir_name/* | sort -h 
-0.2G    dir2 
-0.3G    dir3 
-1.6G    dir1 
-</code> 
-</WRAP> 
- 
-容量の降順ソート\\ 
-<WRAP prewrap 100%> 
-<code> 
-$ du -h -s dir_name/* | sort -hr 
-1.6G    dir1 
-0.3G    dir3 
-0.2G    dir2 
-</code> 
-</WRAP> 
- 
 du コマンドのヘルプ\\ du コマンドのヘルプ\\
-<panel id="repoquery_help_panel" type="default" title="+ ヘルプ [-h,--help]">+<accordion id="du_help" collapsed="false"> 
 +<panel id="du_help_panel" type="default" title="+ ヘルプ [--help]">
 <WRAP color_term> <WRAP color_term>
 <WRAP color_command><html><pre> <WRAP color_command><html><pre>
行 337: 行 316:
 </WRAP> </WRAP>
 </panel> </panel>
 +</accordion>
 +
 +dir_name の容量表示\\
 +<WRAP prewrap 100%>
 +<code>
 +$ du -h -s dir_name
 +1.6G    dir_name
 +</code>
 +</WRAP>
 +
 +dir_name 配下のサブディレクトリ毎の容量表示\\
 +<WRAP prewrap 100%>
 +<code>
 +$ du -h -s dir_name/*
 +1.6G    dir1
 +0.2G    dir2
 +0.3G    dir3
 +</code>
 +</WRAP>
 +
 +dir_name 配下のすべてのサブディレクトリとファイル容量表示(降順, 上位50件)\\
 +※ファイルのみの表示はできない😅\\
 +<code>
 +$ du -kha dir_name/* --exclude={exclude_dir1,exclude_dir2,exclude_dir3} | sort -rn | head -50
 +</code>
 +find コマンドならファイルのみサイズ表示できる🤤\\
 +<code>
 +$ find ./dir_name -ls | sort -rh -k 7 | head -50
 +$ find ./dir_name -printf "%s %M %n %u %g %b %TD %TR %p\n" | sort -hr | head -50
 +</code>
 +
 +容量の昇順ソート\\
 +<WRAP prewrap 100%>
 +<code>
 +$ du -h -s dir_name/* | sort -h
 +0.2G    dir2
 +0.3G    dir3
 +1.6G    dir1
 +</code>
 +</WRAP>
 +
 +容量の降順ソート\\
 +<WRAP prewrap 100%>
 +<code>
 +$ du -h -s dir_name/* | sort -hr
 +1.6G    dir1
 +0.3G    dir3
 +0.2G    dir2
 +</code>
 +</WRAP>
  
 [[https://kazmax.zpp.jp/cmd/d/du.1.html|du - コマンド (プログラム) の説明 - Linux コマンド集 一覧表]]\\ [[https://kazmax.zpp.jp/cmd/d/du.1.html|du - コマンド (プログラム) の説明 - Linux コマンド集 一覧表]]\\
  • linux/commands/file_directory.1705898042.txt.gz
  • 最終更新: 2024/01/22 13:34
  • by ともやん