Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个 .CSV 文件,其中包含大约 15 个字段,我需要将日期列(文件中的第一个字段)从 dd/mm/yyyy 转换为 yyyy/mm/dd。请指教...
使用 awk 这拆分$1为三个部分并将它们连接回 new $1,然后打印所有1
$1
1
echo "30/05/2013 some data" | awk '{split($1,a,"/");$1=a[3]"/"a[2]"/"a[1]}1' 2013/05/30 some data
这可能对您有用(GNU sed):
sed -i -r 's|(..)/(..)/(....)|\3/\2/\1|' file