LoginSignup
0
0

More than 3 years have passed since last update.

【bash】コマンドラインでファイル操作まとめ

Last updated at Posted at 2019-06-14

ファイルの作成

touch index.html

ディレクトリ内にも直接作れる

touch 既存ディレクトリ名/ファイル名

ディレクトリ作成

mkdir sample/

make directoryの略。

名前変更

mv 旧ファイル名 新ファイル名

ディレクトリでもいける。これは「-r」をつけなくてもいける。

削除

rm ファイル名
rm -r ディレクトリ名

ファイルコピー

cp コピー対象 コピー先

-rをつけるとディレクトリごと

cp -r poyo/ poyo2/

編集(使いにくい

echo
元々存在しないファイルを指定した場合、そのファイルが自動生成される。

echo 'ぽよ' > index.html

中身が「ぽよ」だけになる。=全て上書き

echo 'ぽよ' >> index.html

中身に「ぽよ」が追加される

echo > 'ぽよ'

とやると謎の「ぽよ」ができる。拡張子なし謎ファイル

0
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
0
0