
如何去除[
從 ”[19/Mar/2020:05:57:09
“使用sed
或awk
?
我需要[
從日誌檔案的日期和時間中刪除“”。
答案1
這裡有一些解決方案:
# Remove with tr and write changes to second file
tr -d '[' < file > file_edited
# Remove with sed and write changes to second file
sed 's/\[//' file > file_edited
# Remove with sed and edit the file inplace!
sed -i 's/\[//' file
請注意,tr
解決方案將刪除[
檔案中的所有內容,sed
解決方案將刪除每行的第一行[
。如果這不完全是您想要的,您需要編輯您的問題並提供更多詳細資訊。