批处理之家's Archiver

netdzb 发表于 2020-4-15 12:39

Shell脚本如何换行

tes.txt格式如下,如何换行


100034,0

100056,2

100047,4

100021,0


----------------


#!/bin/bash

echo $(cat tes.txt|awk -F ',' '{print $2;}')


没有得到换行,输出这个结果


0 2 4 0,我想得到


0

2

4

0

应该怎么改?

Batcher 发表于 2020-4-15 14:46

[b]回复 [url=http://bbs.bathome.net/redirect.php?goto=findpost&pid=228262&ptid=55442]1#[/url] [i]netdzb[/i] [/b][code]echo "$(awk -F ',' '{print $2;}' tes.txt)"[/code][code]awk -F ',' '{print $2;}' tes.txt[/code]

bailong360 发表于 2020-4-16 10:39

[code]cut -d',' -f2 tes.txt[/code]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.