文件内容
cat
test
.txt
reportType
orderId
sid
hospitalName
customerName
customerSex
customerPhone
customerId
orderNum
doctorName
recordName
symptom
docSymptom
diagnosis
checkResult
medicine
surgery
prevTreatment
curMedHistory
prevMedHistory
bodyCheck
|
Merge multiple lines
1
2
|
tr
-s
"\n"
" "
<
test
.txt ;
echo
reportType orderId sid hospitalName customerName customerSex customerPhone customerId orderNum doctorName recordName symptom docSymptom diagnosis checkResult medicine surgery prevTreatment curMedHistory prevMedHistory bodyCheck medicalOrders check imgs docImages channelId brokerId brokerAvator reportSelf status createdAt updatedAt isDeleted version lock
|
Method 1 is added after merging,
1
2
|
echo
`
tr
-s
"\n"
" "
<
test
.txt;
echo
` |
sed
"s/ /,/g"
reportType,orderId,sid,hospitalName,customerName,customerSex,customerPhone,customerId,orderNum,doctorName,recordName,symptom,docSymptom,diagnosis,checkResult,medicine,surgery,prevTreatment,curMedHistory,prevMedHistory,bodyCheck,medicalOrders,check,imgs,docImages,channelId,brokerId,brokerAvator,reportSelf,status,createdAt,updatedAt,isDeleted,version,lock
|
Method Two
1
|
echo
`
sed
"/^$/d"
test
.txt |
sed
"s@\(.*\)@\1,@g"
`
|
First delete the blank line of the file, add it, and then print it to a line