我的航向是一条航道,正从像:
There are 5 apples and 7 oranges
我也想把5和7个变量带入冲变数,并存在问题。
awk{印刷3,6 }由于如果存在香蕉,其地位可能发生变化而赢得了t work。 两位数如果能够与他们的成果挂钩,就可点数。
预 收
我的航向是一条航道,正从像:
There are 5 apples and 7 oranges
我也想把5和7个变量带入冲变数,并存在问题。
awk{印刷3,6 }由于如果存在香蕉,其地位可能发生变化而赢得了t work。 两位数如果能够与他们的成果挂钩,就可点数。
预 收
并取得果实:
echo There are 5 apples and 7 oranges | grep -o -E [[:digit:]]+ [[:alpha:]]+
a. 只使用一种双管齐下的方法:
str=" There are 5 apples, 12 bananas and 7 oranges"
i=0
while [[ "$str" =~ ([0-9]+)" "([a-z]+)(.*) ]] ; do
num[$i]=${BASH_REMATCH[1]}
type[$i]=${BASH_REMATCH[2]}
str=${BASH_REMATCH[3]}
(( i++ ))
done
for (( i=0; i<${#num[@]}; i++ )); do
printf "%4d %s %s
" $i ${num[$i]} ${type[$i]}
done
产出
0 5 apples
1 12 bananas
2 7 oranges
回答:
echo There are 5 apples and 7 oranges | grep -o -E [[:digit:]]+
缩略语:
<代码> 共有5个 app子和7个 or子——o [0-9]+w+。
但请注意,<代码>w为[:alnum:]
的同义词,因此也将与“appl3s”等同。
彩礼是一种奇怪的语言,你可以做冰。 例如:
a="there are 7 apples"
for i in $a; do
case $i in
[0-9]*)
value=$i
expectname=1
;;
*)
test -n "$expectname" && name=$i
expectname=
;;
esac
done
echo $value
echo $name
如果你不止一次,你就可以填写一个阵列或一个巴什图。
I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...
How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks
I like to write bash shell scripts on my iPhone, put them in an app folder with an icon, plist, etc., so they execute like apps by tapping their icon on SpringBoard. This is not interactive like ...
From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...
I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...
I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...
I m 试图撰写一个双面文字,处理一个文件清单,其名字在投入档案中每栏一栏储存,就像一个一样。
Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...