Prvt_Yadv 编写了一些代码来解释如何使用脚本从文本文件中的包列表安装包。
我的问题是有人能解释一下他为什么选择他选择的组合吗?
我能够不使用上述方法使其工作,但它很不稳定。
我的代码:
#!/bin/bash
#=====================================
# Path to Instalation & Scripts
#=====================================
path2Dev="/home/`id -u -n`/Development/Install"
input="$path2Dev/DepList_Fedora.txt"
#--------------------------------------
#=====================================
## Make stringBuild Global
#=====================================
export stringBuild=" "
#--------------------------------------
#=====================================
## Build string with no Fluff
## from List of packages
#--------------------------------------
while IFS= read -r line
do
stringBuild+=" $line"
done < "$input"
### End of Loop ###
#############################
# Get Dependencys for Build
# from values in ("input")
#============================
sudo dnf group install --assumeyes "C Development Tools and Libraries" ;
echo $stringBuild ## De-Bug
sudo dnf install --assumeyes "$stringBuild"
## Tried `$stringBuild` and $stringbuild
Prvt_Yadv 代码:
sudo dnf install --assumeyes $(awk -F ',' 'BEGIN {ORS=" "} {for(i=1;i<=NF;i++) {print $i}}' $input)
为什么这看起来比我的原始代码更可靠?你能解释一下为什么吗?
DepList_Fedora.txt
bison-devel
arm-none-eabi-gcc
arm-none-eabi-gcc-cs
arm-none-eabi-gcc-cs-c++
arm-none-eabi-binutils-cs
patch
gperftools-devel
ncurses-devel
cdk
cdk-devel
ccrtp
ccrtp-devel
doxygen
python3-hidapi
mingw64-hidapi
hidapi-devel
xclip
autoconf213
libtool-ltdl-devel
python2-devel
guile
nodejs-node-expat
mingw64-libltdl
libusb-devel
libusb
autoconf
texinfo
libtool
libftdi-devel
gcc-arm-linux-gnu
flex
gperf
git
bison
zlib