gpt4 book ai didi

bash - 使用sed删除文件中的括号

转载 作者:行者123 更新时间:2023-12-04 07:01:00 26 4
gpt4 key购买 nike

谁能帮我删除文件中的括号?
这是我的脚本..

  #!/bin/bash

for file in fftw is_c mpi_tile pmb tau xhpl
do
for state in C0 C1 C2 C4
do
printf "${file}_${state}_v1.xls"

sed -e 's/\(//' ${file}_${state}_v1.xls
sed -e 's/\)//' ${file}_${state}_v1.xls

awk '{sum+=$3} ; END {print " ", sum/NR}' ${file}_${state}_v1.xls >> c-state-residency.xls
done
done

最佳答案

简短回答:使用 --in-place用 sed 做你认为你在做的事情。

您正在删除括号,而不是括号,并且只删除每行中的第一个(或者,如果您删除了不需要的 \)。对于 Excel 电子表格,这似乎也是一件奇怪的事情。

您可能希望将 sed 命令的输出通过管道传输到 awk,而不是在适当的位置修改文件...

关于bash - 使用sed删除文件中的括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1849258/

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