LoginSignup
1
0

More than 3 years have passed since last update.

備忘録としてまとめる。

ls

  • * 任意の文字列
  • ? 任意の1文字
$ls *.html
Index.html home.html

$ls /bin/x???
/bin/zcat /bin /bin/zcmp  /bin/znew

オプション

ファイルの詳細情報を表示する。
$ls -l
drwx------+  4 ryohei.udagawa  staff   128  9 16 14:25 Movies
drwx------+  3 ryohei.udagawa  staff    96  9  9 16:17 Music
drwx------+  4 ryohei.udagawa  staff   128  9 16 16:08 Pictures
drwxr-xr-x+  4 ryohei.udagawa  staff   128  9  9 16:17 Public

隠しファイルも含めた全てのファイルを表示する。
$ls -a
.            .ssh            Library
..            .vscode            Movies

ファイル種別を表示する
$ls -F
Applications/    Downloads/    Music/        workspace/
Desktop/    Library/    Pictures/

cat

% cat -n /etc/hosts

1    ##
2    # Host Database
3    #
4    # localhost is used to configure the loopback interface
5    # when the system is booting.  Do not change this entry

less(catより広く見れる)

$less ファイル名

/<文字列>  下方向に向かって検索
?<文字列>  上方向に向かって検索

rm(削除)

ディレクトリも合わせて削除する
rm -r dir

ファイルを削除する際に警告文を表示しない
rm -f file

ファイルの削除前に確認する
rm -I file

mv

mv 移動元 移動先

#ファイル名を変更
$mv file file1

#ファイルを移動(移動先がディレクトリならば、ファイル移動)
$mv file1 dir/

上書きする前に確認する
$mv -I file file1

cp

cp コピー元 コピー先

#ファイルをコピー
$cp file new_file

#ファイルをディレクトリ内にコピー
$cp file dir

上書きする前に確認する
$cp -i file new_file

ディレクトリをコピーする
$cp -r dir new_dir  

find

find 検索開始ディレクトリ 検索条件 アクション

ファイル名を指定してファイルを検索。ファイル名の大文字小文字を区別する
$find .-name README.md

#ワイルドカードが使える。*を使って指定する時は''で囲うこと
$find . -name '*.html' -print

ファイル名を指定してファイルを検索。ファイル名の大文字小文字を区別しない
$find . -iname readme.md

# -type fは通常ファイル
$find . -type f -print

#-type | はシンポリックリンク
find . -type | -print

#-type dはディレクトリ
$find . -type d -print

複数の検索条件を指定。なお、-aは省略可能
$find . -type d -a -name images -print
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0