LoginSignup
0
0

More than 5 years have passed since last update.

シェルスクリプトでコマンド標準出力結果をタブ区切りでcsvにする

Last updated at Posted at 2018-10-02

あまり探せなかったのでメモ
ついでにsed -e "s/^/text /"でコマンドの行頭に文字を追加したいパターンも入れている。

ファイルを経由する場合
$ ls -l > test.txt 
$ sed -e "s/^/text /" test.txt | tr -s ' ' '\t'

コマンドから直接
$ ls -l | sed -e "s/^/text /" | tr -s ' ' '\t'

参考
https://linux.just4fun.biz/?%E9%80%86%E5%BC%95%E3%81%8DUNIX%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89/%E8%A4%87%E6%95%B0%E3%82%B9%E3%83%9A%E3%83%BC%E3%82%B9%E3%81%8C%E5%8C%BA%E5%88%87%E3%82%8A%E3%81%A8%E3%81%AA%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%82%92CSV%E3%81%AB%E5%A4%89%E6%8F%9B%E3%81%99%E3%82%8B

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0