gpt4 book ai didi

linux - 删除每行末尾的 ';'

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:43:53 26 4
gpt4 key购买 nike

我在 Linux 服务器上有一个巨大的 (10+ GB) .csv 文件。线条看起来像这样:

6;20000327;20000425;990099,0;20000327;LL;UBXO;7;-1;62;F;30;001;NO;NO;wgB;0;99;0002;5530;001;708;196;1;AA;N;N;100;53,81;0;0;0;1;1;;1;6;20000327;20000425;990099,0;20000425;LL;OLD*;62;62;92;F;30;001;NO;NO;ueB;0;99;0002;XXXX;001;;;1;AA;N;N;;;0;0;1;0;0;;30;

I am searching for a fast script to do the following:

  1. change any occurrence of <number>,<number> to <number>.<number>
  2. delete the last semicolon of each line

I have especially problems with the second one, because the script shouldn't mind if it is a Linux file or a windows file.

I tried to do it with sed but failed thus far.

[edit]

I finally used a mix of Dennis Williams and SiegeX solutions:

sed 's/;\([0-9]*\),\([0-9]*\);/;\1.\2;/g;s/;\(\r\?\)$/\1/' inputfile

(带有 s/;[[:blank:]]*$//的部分在我的文件中不起作用...)

最佳答案

sed 's/;\([0-9]*\),\([0-9]*\);/;\1.\2;/g;s/;[[:blank:]]*$//' ./infile

关于linux - 删除每行末尾的 ';',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5184031/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com