我有三个文件:
文件1
one
uno
un
1
文件2
two
dos
2
文件 3 三 特雷斯 三位一体 3
这是我的脚本:
#!/system/bin/bash
list=($(cat /sdcard/lst1 ))
list2=($(cat /sdcard/lst2 ))
list3=($(cat /sdcard/lst3 ))
for i in ${!list[*]} ; do
echo -e "${list[$i]} ${list2[$i]}
${list3[$i]} ; done
这里是我得到的输出:
one two three
uno dos tres
un 2 trois
1 3
这里是期望的输出:
one two three
uno dos tres
un trois
1 2 3
我也试过:
IFS=$'\n' ; set -f ;
但是还是不行...
我需要更改什么?
它在 Android 上,没有粘贴
命令。
最佳答案
paste f1 f2 f3
应该做给你的工作
one two three
uno dos tres
un trois
1 2 3
编辑:在默认情况下粘贴不可用的 android 中
如果 file1、file2、file3 是三个文件,那么下面的脚本就可以完成这项工作
awk '{line[FNR]=(line[FNR]=="")?$0:line[FNR] "\t" $0}END{for(i=1;i<=FNR;i++){print line[i]}}' file*
输出
one two three
uno dos tres
un trois
1 2 3
引用资料
- awk [ String Concatenation ]
- awk [ For Statement ] .
关于android - For循环多个数组并保留空行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41205646/