【发布时间】:2016-10-03 15:19:40
【问题描述】:
我正在阅读一个 test.txt 文件。格式:
79033d0135a21e45c60e283785f5914b
dde8d97a40cd22667ccb3ca972197586
4fd5ea73cd51db256384fb3333b0eb3d
我正在逐行读取此文件并将其拆分为(例如,第 1 行:79 03 3d 01 35 a2 1e 45 c6 0e 28 37 85 f5 91 4b)
bash 脚本是:
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
a="$line" | cut -c1-2
b="$line" | cut -c3-4
c="$line" | cut -c5-6
d="$line" | cut -c7-8
e="$line" | cut -c9-10
f="$line" | cut -c11-12
g="$line" | cut -c13-14
h="$line" | cut -c15-16
i="$line" | cut -c17-18
j="$line" | cut -c19-20
k="$line" | cut -c21-22
l="$line" | cut -c23-24
m="$line" | cut -c25-26
n="$line" | cut -c27-28
o="$line" | cut -c29-30
p="$line" | cut -c31-32
#./a.out "$a" "$b" "$c" "$d" "$e" "$f" "$g" "$h" "$i" "$j" "$k" "$l" "$m" "$n" "$o" "$p"
echo "$line"
echo "$a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p"
done < test_10.txt
现在我只是想打印变量。我打算稍后将它们作为命令行参数传递给我的 C++ 程序。
问题是,我无法打印变量。当然,我的 C++ 程序也不能接受参数。
我做错了什么?
【问题讨论】:
标签: bash file split line command-line-interface