如何写击花式缩进多行括号扩展? [英] How to write fancy-indented multi-line brace expansion in Bash?

查看:348
本文介绍了如何写击花式缩进多行括号扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处理一个行这样的:

 的mkdir -p$ DEST_ROOT_PATH /{$ DEST_DIR1,$ DEST_DIR2,...,$ DEST_DIRN}

这行是很长。我希望削减它,它的宽度将放入一个80列线。我试图逃跑用反斜杠线的末端,但空间alignement打破了扩展:

  $回声哈{A,B,\\
> C}
哈{A,B,C}


解决方案

您可以使用这个恶心的黑客。

 回声哈{A,B,\\
> ``C}

它打开与什么也没有一个子shell,但如此扩张只是看到一个空的空间扩充之前得到处理。

I'm dealing with a line such :

mkdir -p "$DEST_ROOT_PATH/"{"$DEST_DIR1","$DEST_DIR2", ..., "$DEST_DIRN"}

This line is quite long. I want to cut it so its width will fit into a 80 columns line. I tried to escape an end of line with a backslash, but space alignement breaks the expansion :

$ echo "ha"{a,b,\
>           c}
ha{a,b, c}

解决方案

You could use this disgusting hack.

echo "ha"{a,b,\
> `      `c}

It opens a subshell with nothing in it, but gets processed before the expansion so the expansion just sees an empty space

这篇关于如何写击花式缩进多行括号扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆