1
我有一個由「|」分隔的四列文件如下將日期插入以「|」分隔的文件的空列中
23414|test doc for me||
32322|test doc for you|2004_12_03|
13454|test doc for all||2010_11_01
我試圖插入當前系統日期爲空列的,這樣輸出應該看起來像如
23414|test doc for me|2018_04_03|2018_04_03
32322|test doc for you|2004_12_03|2018_04_03
13454|test doc for all|2018_04_03|2010_11_01
下面
是我正在試圖代碼
for file in `ls -rlt Added_to_* | awk '{print $9}'`
do
now="$(date +'%Y/%m/%d')"
echo "Running for: $file"
awk -F'|' -v curr="$now" '{
if($3=="" || $4==""){
if ($3=="") { print "$curr"}
if ($4=="") { print "$curr"}
}else
do_something ;
}' $file
done