bash alias rename function with arguments

perl -pe 's|\d+,(\S+)$|join "\t", (split /:/, $1)[4,5]|e' data

Результат

19  54240283    .   T   C   .   .   .    18     189
1   103020      .   A   C   .   .   .    2      2
2   8797402     .   G   A   .   .   .    3      0
0
16.08.2017, 00:10
1 ответ

В псевдониме нельзя использовать аргументы. (Вы можете добавлять элементы после него, но это только усложняет ситуацию. )Вот что о них говорится на справочной странице(man bash):

The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is replaced by the text of the alias. [...]

There is no mechanism for using arguments in the replacement text. If arguments are needed, a shell function should be used. [...]

For almost every purpose, aliases are superseded by shell functions.

Итак, вместо псевдонима следует использовать функцию.

rp() { rename "s{$1}{}" *; }    # No "{}" characters in the substitution

Использование

rp 'the.'    # Quotes optional but recommended. Remember. represents any character
3
28.01.2020, 02:24

Теги

Похожие вопросы