![データをExcelにフォーマットする[閉じる]](https://linux33.com/image/187328/%E3%83%87%E3%83%BC%E3%82%BF%E3%82%92Excel%E3%81%AB%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88%E3%81%99%E3%82%8B%5B%E9%96%89%E3%81%98%E3%82%8B%5D.png)
txtファイルには、次の形式の大量のデータがあります。ご覧のとおり、各行にはヘッダーとパスがあります。ここで必要なのは、Excelのタイトル:パスなど、データを隣に表示する必要があることです。
誰でもこの問題を助けることができますか?
現在の結果
Title:Projects and Ideas
Path:/content/en_us/
Title:buying-guide
Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors
Path:/content/en_us/buying-guide/choose-exterior-paint-colors
Title:Water Softener Buying Guide
Path:/content/en_us/buying-guide/water-softener-buying-guide
Title:Presentation Page
Path:/content/en_us/buying-guide/presentation-page
予想される結果
Title:Projects and Ideas Path:/content/en_us/
Title:buying-guide Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors Path:/content/en_us/buyingguide/choose
Title:Water Softener Buying Guide Path:/content/en_us/buying-guide/water
Title:Presentation Page Path:/content/en_us/buying-guide/presentation-page
答え1
ファイルタブを分割してテーブルに貼り付けたいとします。だからあなたはこれを行うことができます:
$ sed 'N;s/\n\(Path.*\)$/\t\1/' file
Title:Projects and Ideas Path:/content/en_us/
Title:buying-guide Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors Path:/content/en_us/buying-guide/choose-exterior-paint-colors
Title:Water Softener Buying Guide Path:/content/en_us/buying-guide/water-softener-buying-guide
Title:Presentation Page Path:/content/en_us/buying-guide/presentation-page
ExcelはUnix / Linuxではありませんが、LibreOfiice CalcなどのLinuxで利用可能なオフィスソフトウェアにも同じ質問が適用されるため、私の答えです。