在cat / column环境中将文件打印在一行中

时间:2012-12-19 17:51:59

标签: bash cat

我需要在cat / column环境中的一行中打印文件列表。问题是 - 它以多行打印:

#!/bin/bash

Files=`ls ~/`

echo $Files # prints in one line as I want. But I have to do it inside cat/column:

# prints files in column -- despite column separator is &:
cat << EO | column -s\& -t

$Files

EO

1 个答案:

答案 0 :(得分:2)

没有cat

,您可以达到同样的效果
echo $Files | column -s\& -t

这不会产生cat的问题。


对于该输入已在链接中给出:

    column -s\& -t <(echo "  -a, --all & apply the sed script to files in current dir and subdirs
-d, --dirs & apply the sed script to first-level-dir names
-f, --file & apply the sed script to a given file. It is a single command, but the script keep You from getting into manuals
-h, --help & show this output
-s, --script & the sed script to be used (currently: `ls $(dirname $0)/scripts`)
-v, --version & show version information
-I, --noi & overwrite existing files")

会起作用。