是否有可能结合bash和awk脚本文件? [英] Does it possible combine bash and awk script files?
问题描述
我有一些bash脚本,我得到变量的值,我想在awk中使用。
它是否可能包括全AWK(如可能使用bash脚本文件)文件,在bash例如:
#!/ bin / sh的
VAR1 = $ 1
来源myawk.sh
和myawk.sh:
打印$ 1;
首先,如果你正在写的bash不要使用#!/ bin / sh的
这将让你在兼容模式下它仅necessarly如果你正在写的可移植性(然后你必须坚持POSIX标准的附录)。
现在关于你的问题,你只需要从你的bash脚本里面运行的awk,像这样的:
#!/斌/庆典
VAR1 = $ 1
AWK -f myawk.sh
也应该使用.awk作为扩展名,我猜。
I have some bash script where I get values of variable, that I would like use in awk. Does it possible include whole awk (like it possible with bash script files) file in bash e.g.:
#!/bin/sh
var1=$1
source myawk.sh
and myawk.sh:
print $1;
first of all, if you're writing bash don't use #!/bin/sh
that will put you in compatibility mode which is only necessarly if you're writing for portability (and then you have to adhere to the POSIX normative).
now regarding your question you just have to run awk from inside your bash script, like this:
#!/bin/bash
var1=$1
awk -f myawk.sh
also you should use .awk as extension I guess.
这篇关于是否有可能结合bash和awk脚本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!