空のファイルの作成

空のファイルの作成

きっと方法があるとは分かりますが、実力がそれほど良くはありません。

ベストアンサー1

空のファイルの作成

見るだけでも作ることができtouch、組み合わせも可能ですBash 範囲拡張これを簡単にするには、次の手順を実行します。

touch somefile  # Will create a single file called `somefile`
touch somefiles{01..10} # Will create 10 files called `somefile01` to `somefile10`
touch some{bar,baz} # Will create a file called `somebar` and one called `somebaz`

コンテンツを含むファイルの作成

Bashリダイレクトを使用して、コマンド出力をファイルにリダイレクトできます。

echo "some content" > somefile
ls > somefile

または、より長い固定入力には次のものを使用できます。ここのドキュメント:

cat <<EOF >somefile
some multi
line
file
EOF

おすすめ記事