Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
sedを使用して入力の各行を複製したい。つまり、入力が次のようになった場合:
first secod third fourth ...
出力を次のようにしたい:
first first second second third third fourth fourth ... ...
等々。
sed を使用してこれが不可能な場合、何をお勧めしますか? 私は最も単純な解決策を好みます。
pasteこれは、コマンドに合わせて作成されたジョブのようです:
paste
paste -d " " file file
awk を使用し、
awk '{print $1, $1}' file
またはコメントされているように、単語に空白が含まれている場合は、次のことができます。
awk '{print $0, $0}' file