sed 好工具

当你的实验产生了很多相同样式的数据文件时,如果有 1000 个这样的文件,我们不太可能针对每一个文件单独进行操作。如果某数据文件 (.csv) 的开头几行是这样的,需要进行删除操作。

# This is for XYZ experiment
# column 1: time ; column 2: displacement ; ...
# unit:
# s; m; ....

在 linux 中,很容易进行这样的操作。如:对第 1~4 行的数据进行删除,在 Terminal 中进入到该文件夹,然后运行:

find . -iname '*.csv' -execdir sed -i '1,6d' {} \;



find . -iname '*.csv' -execdir sed -i s/";$"//g {} \;

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see


This site uses Akismet to reduce spam. Learn how your comment data is processed.