问题是:显示每行文本中的 和 字符。
这是我的代码:
while read line
do
a=`echo $line | cut -c 2`
b=`echo $line | cut -c 7`
echo -n $a
echo $b
done
Run Code Online (Sandbox Code Playgroud)
问题是当第一个字符是空格时,它不会打印空格。例如,
Input:
A big elephant
Expected output:
e
My output:
e
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?