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.
ここで簡単な質問があります:
ファイルのグループの行を分離しようとしているとしましょう。それらはすべて次のようになります。
pidテキスト番号
そして、pidを使用して行を異なるファイルに分割したいのですが、どうすればこれを実現できますか?
これまでのところ、私は次のようなことを試しました:
cat files | grep '\([0-9]\{3\}\)' > $1.txt
もちろん、うまくいきません。何かアイデアはありますか?
pids を含むファイル:
$ cat /tmp/l 123 azerty 234 qwerty 456 bepo
awk コード:
$ awk '/^[0-9]{3}/{print $0 > $1".txt"}' /tmp/l
の出力ls:
ls
$ ls 123.txt 234.txt 456.txt