我想在4列中打印输出文本:
SharedCacheMap 0xb89e9720 None \Device\HarddiskVolume1\Windows\System32\WWanAPI.dll
ImageSectionObject 0xb89ea5f8 None \Device\HarddiskVolume1\Program Files\McAfee\Host Intrusion Prevention\Resource\0409\McTrayHipRL.dll
DataSectionObject 0xb89ea5f8 None \Device\HarddiskVolume1\Program Files\McAfee\Host Intrusion Prevention\Resource\0409\McTrayHipRL.dll
我试过了:
column -s " " -t
我不知道如何处理文件路径中的空格。
提前感谢您的帮助!
答案 0 :(得分:1)
试试这个:
while read -r c1 c2 c3 rest; do printf "%-20s %-12s %-8s %s\n" "$c1" "$c2" "$c3" "$rest"; done < file
输出:
SharedCacheMap 0xb89e9720 None \Device\HarddiskVolume1\Windows\System32\WWanAPI.dll ImageSectionObject 0xb89ea5f8 None \Device\HarddiskVolume1\Program Files\McAfee\Host Intrusion Prevention\Resource\0409\McTrayHipRL.dll DataSectionObject 0xb89ea5f8 None \Device\HarddiskVolume1\Program Files\McAfee\Host Intrusion Prevention\Resource\0409\McTrayHipRL.dll
答案 1 :(得分:0)
仅使用sed删除文件名字符串中的空格
cat yourfile.txt | sed 's/[^\]*\\/&\$\n/' | sed '2~2 s/ //g' | sed ':a; N; $! ba; s/\$\n//g'
或用%20替换它们
cat yourfile.txt | sed 's/[^\]*\\/&\$\n/' | sed '2~2 s/ /%20/g' | sed ':a; N; $! ba; s/\$\n//g'