Bash

在文件中列印序列

  • May 19, 2019

我想在新文件的列中列印以下內容

1_number_density_per_atom_1.xvg
1_number_density_per_atom_2.xvg
1_number_density_per_atom_3.xvg
.
.
.
1_number_density_per_atom_653.xvg

所以我想這個想法會是寫類似的東西

printf "%s\n" "1_number_density_per_atom_1.xvg" "1_number_density_per_atom_2.xvg" "1_number_density_per_atom_3.xvg" ... "1_number_density_per_atom_653.xvg" > test.dat

使用大括號擴展

printf "%s\n" 1_number_density_per_atom_{1..653}.xvg > test.dat

使用GNU seq

seq -f 1_number_density_per_atom_%g.xvg 653 > test.dat

引用自:https://unix.stackexchange.com/questions/519446